Example usage for java.awt Rectangle Rectangle

List of usage examples for java.awt Rectangle Rectangle

Introduction

In this page you can find the example usage for java.awt Rectangle Rectangle.

Prototype

public Rectangle(int x, int y, int width, int height) 

Source Link

Document

Constructs a new Rectangle whose upper-left corner is specified as (x,y) and whose width and height are specified by the arguments of the same name.

Usage

From source file:io.github.dsheirer.spectrum.SpectrumPanel.java

/**
 * Draws the current fft spectrum with a line and a gradient fill.
 *///from   w w  w  . jav a2 s.c om
private void drawSpectrum(Graphics2D graphics) {
    Dimension size = getSize();

    //Draw the background
    Rectangle background = new Rectangle(0, 0, size.width, size.height);
    graphics.setColor(mColorSpectrumBackground);
    graphics.draw(background);
    graphics.fill(background);

    //Define the gradient
    GradientPaint gradient = new GradientPaint(0, (getSize().height - mSpectrumInset) / 2,
            mColorSpectrumGradientTop, 0, getSize().height, mColorSpectrumGradientBottom);

    graphics.setBackground(mColorSpectrumBackground);

    GeneralPath spectrumShape = new GeneralPath();

    //Start at the lower right inset point
    spectrumShape.moveTo(size.getWidth(), size.getHeight() - mSpectrumInset);

    //Draw to the lower left
    spectrumShape.lineTo(0, size.getHeight() - mSpectrumInset);

    float[] bins = getBins();

    //If we have FFT data to display ...
    if (bins != null) {
        float insideHeight = size.height - mSpectrumInset;

        float scalor = insideHeight / -mDBScale;

        /* Calculate based on bin size - 1, since bin 0 is rendered at zero
           * and the last bin is rendered at the width */
        float binSize = (float) size.width / ((float) (bins.length));

        for (int x = 0; x < bins.length; x++) {
            float height;

            height = bins[x] * scalor;

            if (height > insideHeight) {
                height = insideHeight;
            }

            if (height < 0) {
                height = 0;
            }

            float xAxis = (float) x * binSize;

            spectrumShape.lineTo(xAxis, height);
        }
    }
    //Otherwise show an empty spectrum
    else {
        //Draw Left Size
        graphics.setPaint(gradient);
        spectrumShape.lineTo(0, size.getHeight() - mSpectrumInset);
        //Draw Middle
        spectrumShape.lineTo(size.getWidth(), size.getHeight() - mSpectrumInset);
    }

    //Draw Right Side
    spectrumShape.lineTo(size.getWidth(), size.getHeight() - mSpectrumInset);

    graphics.setPaint(gradient);
    graphics.draw(spectrumShape);
    graphics.fill(spectrumShape);

    graphics.setPaint(mColorSpectrumLine);

    //Draw the bottom line under the spectrum
    graphics.draw(new Line2D.Float(0, size.height - mSpectrumInset, size.width, size.height - mSpectrumInset));
}

From source file:com.funambol.admin.settings.panels.EditRollingFileAppender.java

/**
 * Create the panel//ww w.j a  va  2s .  c o m
 * @throws Exception if error occures during creation of the panel.
 */
private void init() throws Exception {

    final int h = 18;
    final int x1 = 15;
    final int x2 = 150;
    final int w1 = 100;
    final int w2 = 310;

    int y = 40;
    int dy = 25;

    setLayout(null);
    setName(Bundle.getMessage(Bundle.EDIT_ROLLING_FILE_APPENDER_PANEL_NAME));

    panelNameLabel.setText(Bundle.getMessage(Bundle.EDIT_ROLLING_FILE_APPENDER_PANEL_NAME));
    panelNameLabel.setBounds(new Rectangle(14, 5, 245, 28));
    panelNameLabel.setAlignmentX(SwingConstants.CENTER);
    panelNameLabel.setBorder(new TitledBorder(""));

    nameLabel.setText(Bundle.getMessage(Bundle.LABEL_APPENDER_NAME) + " :");
    nameLabel.setBounds(new Rectangle(x1, y, w1, h));
    nameLabel2.setBounds(new Rectangle(x2, y, w2, h));

    y += dy;

    fileNameLabel.setText(Bundle.getMessage(Bundle.LABEL_FILE_NAME) + " :");
    fileNameLabel.setBounds(new Rectangle(x1, y, w1, h));
    fileNameValue.setBounds(new Rectangle(x2, y, w2, h));

    y += dy;

    fileSizeLabel.setText(Bundle.getMessage(Bundle.LABEL_MAX_FILE_SIZE) + " :");
    fileSizeLabel.setBounds(new Rectangle(x1, y, w1, h));
    fileSizeValue.setBounds(new Rectangle(x2, y, w2, h));
    fileSizeValue.setHorizontalAlignment(JTextField.RIGHT);
    limitMBLabel.setBounds(new Rectangle(x2 + w2 + 10, y, 50, h));

    y += dy;

    fileRotationCountLabel.setText(Bundle.getMessage(Bundle.LABEL_MAX_BACKUP_INDEX) + " :");
    fileRotationCountLabel.setBounds(new Rectangle(x1, y, w1, h));
    fileRotationCountValue.setBounds(new Rectangle(x2, y, w2, h));
    fileRotationCountValue.setHorizontalAlignment(JTextField.RIGHT);

    y += dy;

    conversionPatternLabel.setText(Bundle.getMessage(Bundle.LABEL_PATTERN_LAYOUT) + " :");
    conversionPatternLabel.setBounds(new Rectangle(x1, y, w1, h));
    conversionPattern.setBounds(new Rectangle(x2, y, w2, h));

    y += dy;

    noteLabel.setText(Bundle.getMessage(Bundle.LABEL_FILE_APPENDER_NOTE));
    noteLabel.setBounds(new Rectangle(x1, y, 500, h));

    y += dy;
    y += dy;

    confirmButton.setText(Bundle.getMessage(Bundle.LABEL_BUTTON_SAVE));
    confirmButton.setBounds(new Rectangle(401, y, 60, 25));

    confirmButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                validateValues();
                getValues();
                EditRollingFileAppender.this.actionPerformed(new ActionEvent(EditRollingFileAppender.this,
                        ACTION_EVENT_UPDATE, event.getActionCommand()));
            } catch (Exception e) {
                notifyError(new AdminException(e.getMessage()));
            }
        }
    });

    add(panelNameLabel, null);
    add(nameLabel, null);
    add(nameLabel2, null);
    add(fileNameLabel, null);
    add(fileNameValue, null);
    add(fileRotationCountLabel, null);
    add(fileRotationCountValue, null);
    add(fileSizeLabel, null);
    add(fileSizeValue, null);
    add(limitMBLabel, null);
    add(conversionPatternLabel, null);
    add(conversionPattern, null);
    add(noteLabel, null);

    add(confirmButton, null);

    GuiFactory.setDefaultFont(this);
    panelNameLabel.setFont(GuiFactory.titlePanelFont);

}

From source file:de.tor.tribes.ui.panels.MinimapPanel.java

/**
 * Creates new form MinimapPanel//  w  w w .  j a v a 2 s.  c  o  m
 */
MinimapPanel() {
    initComponents();
    setSize(300, 300);
    mMinimapListeners = new LinkedList<>();
    mToolChangeListeners = new LinkedList<>();
    setCursor(ImageManager.getCursor(iCurrentCursor));
    mScreenshotPanel = new ScreenshotPanel();
    minimapButtons.put(ID_MINIMAP, new Rectangle(2, 2, 26, 26));
    minimapButtons.put(ID_ALLY_CHART, new Rectangle(30, 2, 26, 26));
    minimapButtons.put(ID_TRIBE_CHART, new Rectangle(60, 2, 26, 26));
    try {
        minimapIcons.put(ID_MINIMAP, ImageIO.read(new File("./graphics/icons/minimap.png")));
        minimapIcons.put(ID_ALLY_CHART, ImageIO.read(new File("./graphics/icons/ally_chart.png")));
        minimapIcons.put(ID_TRIBE_CHART, ImageIO.read(new File("./graphics/icons/tribe_chart.png")));
    } catch (Exception ignored) {
    }
    jPanel1.add(mScreenshotPanel);
    rVisiblePart = new Rectangle(ServerSettings.getSingleton().getMapDimension());
    zoomed = false;
    MarkerManager.getSingleton().addManagerListener(this);
    TagManager.getSingleton().addManagerListener(this);
    MinimapRepaintThread.getSingleton().setVisiblePart(rVisiblePart);
    if (!GlobalOptions.isMinimal()) {
        MinimapRepaintThread.getSingleton().start();
    }
    addMouseListener(new MouseListener() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (!showControls && e.getButton() != MouseEvent.BUTTON1) {
                //show controls
                Point p = e.getPoint();
                p.translate(-5, -5);
                showControls(p);
                return;
            }
            if (!showControls && iCurrentView == ID_MINIMAP) {
                Point p = mousePosToMapPosition(e.getX(), e.getY());
                DSWorkbenchMainFrame.getSingleton().centerPosition(p.getX(), p.getY());
                MapPanel.getSingleton().getMapRenderer().initiateRedraw(MapRenderer.ALL_LAYERS);
                if (MinimapZoomFrame.getSingleton().isVisible()) {
                    MinimapZoomFrame.getSingleton().toFront();
                }
            } else {
                if (minimapButtons.get(ID_MINIMAP).contains(e.getPoint())) {
                    iCurrentView = ID_MINIMAP;
                    mBuffer = null;
                    showControls = false;
                    MinimapRepaintThread.getSingleton().update();
                } else if (minimapButtons.get(ID_ALLY_CHART).contains(e.getPoint())) {
                    iCurrentView = ID_ALLY_CHART;
                    lastHash = 0;
                    showControls = false;
                    updateComplete();
                } else if (minimapButtons.get(ID_TRIBE_CHART).contains(e.getPoint())) {
                    iCurrentView = ID_TRIBE_CHART;
                    lastHash = 0;
                    showControls = false;
                    updateComplete();
                }
            }
        }

        @Override
        public void mousePressed(MouseEvent e) {
            if (iCurrentView != ID_MINIMAP) {
                return;
            }
            if (iCurrentCursor == ImageManager.CURSOR_SHOT || iCurrentCursor == ImageManager.CURSOR_ZOOM) {
                iXDown = e.getX();
                iYDown = e.getY();
            }
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            if (iCurrentView != ID_MINIMAP) {
                return;
            }
            if (rDrag == null) {
                return;
            }
            if (iCurrentCursor == ImageManager.CURSOR_SHOT) {
                try {
                    BufferedImage i = MinimapRepaintThread.getSingleton().getImage();
                    double widthFactor = ((double) ServerSettings.getSingleton().getMapDimension().width)
                            / getWidth();
                    double heightFactor = ((double) ServerSettings.getSingleton().getMapDimension().height)
                            / getHeight();

                    int x = (int) Math.rint(widthFactor * rDrag.getX());
                    int y = (int) Math.rint(heightFactor * rDrag.getY());
                    int w = (int) Math.rint(widthFactor * (rDrag.getWidth() - rDrag.getX()));
                    int h = (int) Math.rint(heightFactor * (rDrag.getHeight() - rDrag.getY()));
                    BufferedImage sub = i.getSubimage(x, y, w, h);
                    mScreenshotPanel.setBuffer(sub);
                    jPanel1.setSize(mScreenshotPanel.getSize());
                    jPanel1.setPreferredSize(mScreenshotPanel.getSize());
                    jPanel1.setMinimumSize(mScreenshotPanel.getSize());
                    jPanel1.setMaximumSize(mScreenshotPanel.getSize());
                    jScreenshotPreview.pack();
                    jScreenshotControl.pack();
                    jScreenshotPreview.setVisible(true);
                    jScreenshotControl.setVisible(true);
                } catch (Exception ie) {
                    logger.error("Failed to initialize mapshot", ie);
                }
            } else if (iCurrentCursor == ImageManager.CURSOR_ZOOM) {
                if (!zoomed) {
                    Rectangle mapDim = ServerSettings.getSingleton().getMapDimension();
                    double widthFactor = ((double) mapDim.width) / getWidth();
                    double heightFactor = ((double) mapDim.height) / getHeight();

                    int x = (int) Math.rint(widthFactor * rDrag.getX() + mapDim.getMinX());
                    int y = (int) Math.rint(heightFactor * rDrag.getY() + mapDim.getMinY());
                    int w = (int) Math.rint(widthFactor * (rDrag.getWidth() - rDrag.getX()));

                    if (w >= 10) {
                        rVisiblePart = new Rectangle(x, y, w, w);
                        MinimapRepaintThread.getSingleton().setVisiblePart(rVisiblePart);
                        redraw();
                        zoomed = true;
                    }
                } else {
                    rVisiblePart = new Rectangle(ServerSettings.getSingleton().getMapDimension());
                    MinimapRepaintThread.getSingleton().setVisiblePart(rVisiblePart);
                    redraw();
                    zoomed = false;
                }
                MinimapZoomFrame.getSingleton().setVisible(false);
            }
            iXDown = 0;
            iYDown = 0;
            rDrag = null;
        }

        @Override
        public void mouseEntered(MouseEvent e) {
            if (iCurrentView != ID_MINIMAP) {
                return;
            }
            switch (iCurrentCursor) {
            case ImageManager.CURSOR_ZOOM: {
                MinimapZoomFrame.getSingleton().setVisible(true);
            }
            }
        }

        @Override
        public void mouseExited(MouseEvent e) {
            if (MinimapZoomFrame.getSingleton().isVisible()) {
                MinimapZoomFrame.getSingleton().setVisible(false);
            }
            iXDown = 0;
            iYDown = 0;
            rDrag = null;
        }
    });

    addMouseMotionListener(new MouseMotionListener() {

        @Override
        public void mouseDragged(MouseEvent e) {
            if (iCurrentView != ID_MINIMAP) {
                return;
            }
            switch (iCurrentCursor) {
            case ImageManager.CURSOR_MOVE: {
                Point p = mousePosToMapPosition(e.getX(), e.getY());
                DSWorkbenchMainFrame.getSingleton().centerPosition(p.x, p.y);
                rDrag = null;
                break;
            }
            case ImageManager.CURSOR_SHOT: {
                rDrag = new Rectangle2D.Double(iXDown, iYDown, e.getX(), e.getY());
                break;
            }
            case ImageManager.CURSOR_ZOOM: {
                rDrag = new Rectangle2D.Double(iXDown, iYDown, e.getX(), e.getY());
                break;
            }
            }
        }

        @Override
        public void mouseMoved(MouseEvent e) {
            if (iCurrentView == ID_MINIMAP) {
                switch (iCurrentCursor) {
                case ImageManager.CURSOR_ZOOM: {
                    if (!MinimapZoomFrame.getSingleton().isVisible()) {
                        MinimapZoomFrame.getSingleton().setVisible(true);
                    }
                    int mapWidth = (int) ServerSettings.getSingleton().getMapDimension().getWidth();
                    int mapHeight = (int) ServerSettings.getSingleton().getMapDimension().getHeight();

                    int x = (int) Math.rint((double) mapWidth / (double) getWidth() * (double) e.getX());
                    int y = (int) Math.rint((double) mapHeight / (double) getHeight() * (double) e.getY());
                    MinimapZoomFrame.getSingleton().updatePosition(x, y);
                    break;
                }
                default: {
                    if (MinimapZoomFrame.getSingleton().isVisible()) {
                        MinimapZoomFrame.getSingleton().setVisible(false);
                    }
                }
                }
            }
            Point location = minimapButtons.get(ID_MINIMAP).getLocation();
            location.translate(-2, -2);
            if (!new Rectangle(location.x, location.y, 88, 30).contains(e.getPoint())) {
                //hide controls
                showControls = false;
                repaint();
            }
        }
    });

    addMouseWheelListener(new MouseWheelListener() {

        @Override
        public void mouseWheelMoved(MouseWheelEvent e) {

            if (iCurrentView != ID_MINIMAP) {
                return;
            }
            iCurrentCursor += e.getWheelRotation();
            if (iCurrentCursor == ImageManager.CURSOR_DEFAULT + e.getWheelRotation()) {
                if (e.getWheelRotation() < 0) {
                    iCurrentCursor = ImageManager.CURSOR_SHOT;
                } else {
                    iCurrentCursor = ImageManager.CURSOR_MOVE;
                }
            } else if (iCurrentCursor < ImageManager.CURSOR_MOVE) {
                iCurrentCursor = ImageManager.CURSOR_DEFAULT;
            } else if (iCurrentCursor > ImageManager.CURSOR_SHOT) {
                iCurrentCursor = ImageManager.CURSOR_DEFAULT;
            }
            if (iCurrentCursor != ImageManager.CURSOR_ZOOM) {
                if (MinimapZoomFrame.getSingleton().isVisible()) {
                    MinimapZoomFrame.getSingleton().setVisible(false);
                }
            } else {
                MinimapZoomFrame.getSingleton().setVisible(true);
            }
            setCurrentCursor(iCurrentCursor);
        }
    });

}

From source file:Paints.java

/** Draw the example */
public void paint(Graphics g1) {
    Graphics2D g = (Graphics2D) g1;
    // Paint the entire background using a GradientPaint.
    // The background color varies diagonally from deep red to pale blue
    g.setPaint(new GradientPaint(0, 0, new Color(150, 0, 0), WIDTH, HEIGHT, new Color(200, 200, 255)));
    g.fillRect(0, 0, WIDTH, HEIGHT); // fill the background

    // Use a different GradientPaint to draw a box.
    // This one alternates between deep opaque green and transparent green.
    // Note: the 4th arg to Color() constructor specifies color opacity
    g.setPaint(new GradientPaint(0, 0, new Color(0, 150, 0), 20, 20, new Color(0, 150, 0, 0), true));
    g.setStroke(new BasicStroke(15)); // use wide lines
    g.drawRect(25, 25, WIDTH - 50, HEIGHT - 50); // draw the box

    // The glyphs of fonts can be used as Shape objects, which enables
    // us to use Java2D techniques with letters Just as we would with
    // any other shape. Here we get some letter shapes to draw.
    Font font = new Font("Serif", Font.BOLD, 10); // a basic font
    Font bigfont = // a scaled up version
            font.deriveFont(AffineTransform.getScaleInstance(30.0, 30.0));
    GlyphVector gv = bigfont.createGlyphVector(g.getFontRenderContext(), "JAV");
    Shape jshape = gv.getGlyphOutline(0); // Shape of letter J
    Shape ashape = gv.getGlyphOutline(1); // Shape of letter A
    Shape vshape = gv.getGlyphOutline(2); // Shape of letter V

    // We're going to outline the letters with a 5-pixel wide line
    g.setStroke(new BasicStroke(5.0f));

    // We're going to fake shadows for the letters using the
    // following Paint and AffineTransform objects
    Paint shadowPaint = new Color(0, 0, 0, 100); // Translucent black
    AffineTransform shadowTransform = AffineTransform.getShearInstance(-1.0, 0.0); // Shear to the right
    shadowTransform.scale(1.0, 0.5); // Scale height by 1/2

    // Move to the baseline of our first letter
    g.translate(65, 270);/*from w  w w.  jav  a  2  s .  c  o  m*/

    // Draw the shadow of the J shape
    g.setPaint(shadowPaint);
    g.translate(15, 20); // Compensate for the descender of the J
    // transform the J into the shape of its shadow, and fill it
    g.fill(shadowTransform.createTransformedShape(jshape));
    g.translate(-15, -20); // Undo the translation above

    // Now fill the J shape with a solid (and opaque) color
    g.setPaint(Color.blue); // Fill with solid, opaque blue
    g.fill(jshape); // Fill the shape
    g.setPaint(Color.black); // Switch to solid black
    g.draw(jshape); // And draw the outline of the J

    // Now draw the A shadow
    g.translate(75, 0); // Move to the right
    g.setPaint(shadowPaint); // Set shadow color
    g.fill(shadowTransform.createTransformedShape(ashape)); // draw shadow

    // Draw the A shape using a solid transparent color
    g.setPaint(new Color(0, 255, 0, 125)); // Transparent green as paint
    g.fill(ashape); // Fill the shape
    g.setPaint(Color.black); // Switch to solid back
    g.draw(ashape); // Draw the outline

    // Move to the right and draw the shadow of the letter V
    g.translate(175, 0);
    g.setPaint(shadowPaint);
    g.fill(shadowTransform.createTransformedShape(vshape));

    // We're going to fill the next letter using a TexturePaint, which
    // repeatedly tiles an image. The first step is to obtain the image.
    // We could load it from an image file, but here we create it
    // ourselves by drawing a into an off-screen image. Note that we use
    // a GradientPaint to fill the off-screen image, so the fill pattern
    // combines features of both Paint classes.
    BufferedImage tile = // Create an image
            new BufferedImage(50, 50, BufferedImage.TYPE_INT_RGB);
    Graphics2D tg = tile.createGraphics(); // Get its Graphics for drawing
    tg.setColor(Color.pink);
    tg.fillRect(0, 0, 50, 50); // Fill tile background with pink
    tg.setPaint(new GradientPaint(40, 0, Color.green, // diagonal gradient
            0, 40, Color.gray)); // green to gray
    tg.fillOval(5, 5, 40, 40); // Draw a circle with this gradient

    // Use this new tile to create a TexturePaint and fill the letter V
    g.setPaint(new TexturePaint(tile, new Rectangle(0, 0, 50, 50)));
    g.fill(vshape); // Fill letter shape
    g.setPaint(Color.black); // Switch to solid black
    g.draw(vshape); // Draw outline of letter

    // Move to the right and draw the shadow of the final A
    g.translate(160, 0);
    g.setPaint(shadowPaint);
    g.fill(shadowTransform.createTransformedShape(ashape));

    g.fill(ashape); // Fill letter A
    g.setPaint(Color.black); // Revert to solid black
    g.draw(ashape); // Draw the outline of the A
}

From source file:com.funambol.exchange.admin.DefaultExchangeConnectorConfigPanel.java

/**
 * Create the panel/*  ww w. j a  va 2 s. co  m*/
 */
private void init() {

    JLabel title, contactFolderLabel, eventFolderLabel, taskFolderLabel, noteFolderLabel, seccServerLabel,
            seccPortLabel, exchangeServerLabel;
    JPanel seccPanel, exchangePanel, sslPanel;

    title = new JLabel();
    exchangePanel = new JPanel();
    seccPanel = new JPanel();
    sslPanel = new JPanel();

    contactFolderValue = new JTextField();
    eventFolderValue = new JTextField();
    taskFolderValue = new JTextField();
    noteFolderValue = new JTextField();
    seccServerLabel = new JLabel();
    seccServerValue = new JTextField();
    seccPortLabel = new JLabel();
    seccPortValue = new JTextField();
    useSSLValue = new JCheckBox();
    useFBAValue = new JCheckBox();
    useKeyStoreValue = new JCheckBox();
    keyStoreFileNameLabel = new JLabel();
    keyStoreFileNameValue = new JTextField();
    keyStorePasswordLabel = new JLabel();
    keyStorePasswordValue = new JTextField();

    exchangeServerLabel = new JLabel();
    exchangeServerValue = new JTextField();
    exchangeServerNameLabel = new JLabel();
    exchangeServerNameValue = new JTextField();
    setLayout(null);

    title.setFont(GuiFactory.titlePanelFont);
    title.setText("Funambol Exchange Connector");
    title.setBounds(new Rectangle(14, 5, 316, 28));
    title.setAlignmentX(SwingConstants.CENTER);
    title.setBorder(new TitledBorder(""));

    contactFolderLabel = new JLabel();
    contactFolderLabel.setText("Contact Folder: ");
    contactFolderLabel.setBounds(14, 35, 116, 15);
    add(contactFolderLabel);
    contactFolderValue.setBounds(150, 35, 220, 19);
    add(contactFolderValue);

    eventFolderLabel = new JLabel();
    eventFolderLabel.setText("Event Folder: ");
    eventFolderLabel.setBounds(14, 65, 116, 15);
    add(eventFolderLabel);
    eventFolderValue.setBounds(150, 65, 220, 19);
    add(eventFolderValue);

    taskFolderLabel = new JLabel();
    taskFolderLabel.setText("Task Folder: ");
    taskFolderLabel.setBounds(14, 95, 116, 15);
    add(taskFolderLabel);
    taskFolderValue.setBounds(150, 95, 220, 19);
    add(taskFolderValue);

    noteFolderLabel = new JLabel();
    noteFolderLabel.setText("Note Folder: ");
    noteFolderLabel.setBounds(14, 125, 116, 15);
    add(noteFolderLabel);
    noteFolderValue.setBounds(150, 125, 220, 19);
    add(noteFolderValue);

    seccPanel.setLayout(null);
    seccPanel.setBorder(new TitledBorder("HTTP Server Configuration"));

    seccServerLabel.setText("Server:");
    seccPanel.add(seccServerLabel);
    seccServerLabel.setBounds(10, 20, 116, 15);
    seccPanel.add(seccServerValue);
    seccServerValue.setBounds(150, 20, 220, 19);
    seccServerValue.setFont(GuiFactory.defaultFont);

    seccPortLabel.setText("Port:");
    seccPanel.add(seccPortLabel);
    seccPortLabel.setBounds(10, 50, 131, 15);
    seccPanel.add(seccPortValue);
    seccPortValue.setBounds(150, 50, 220, 19);
    seccPortValue.setFont(GuiFactory.defaultFont);

    add(seccPanel);
    seccPanel.setBounds(10, 155, 380, 80);

    exchangePanel.setLayout(null);
    exchangePanel.setBorder(new TitledBorder("WebDav Message Configuration"));

    exchangeServerLabel.setText("Server: ");
    exchangePanel.add(exchangeServerLabel);
    exchangeServerLabel.setBounds(10, 20, 150, 19);
    exchangePanel.add(exchangeServerValue);
    exchangeServerValue.setBounds(150, 20, 220, 19);
    exchangeServerValue.setFont(GuiFactory.defaultFont);

    exchangeServerNameLabel.setText("Name:");
    exchangeServerNameLabel.setBounds(10, 50, 150, 19);
    exchangePanel.add(exchangeServerNameLabel);
    exchangeServerNameValue.setBounds(150, 50, 220, 19);
    exchangeServerNameValue.setFont(GuiFactory.defaultFont);
    exchangePanel.add(exchangeServerNameValue);

    add(exchangePanel);
    exchangePanel.setBounds(10, 255, 380, 80);

    //the ssl option panel

    sslPanel.setLayout(null);
    sslPanel.setBorder(new TitledBorder("SSL"));

    useSSLValue.setText("Use SSL");
    useSSLValue.setSelected(false);
    useSSLValue.setBounds(5, 20, 150, 19);
    sslPanel.add(useSSLValue);

    useFBAValue.setText("Use Form-Based Authentication");
    useFBAValue.setSelected(true);
    useFBAValue.setBounds(5, 40, 250, 19);
    sslPanel.add(useFBAValue);

    useKeyStoreValue.setText("Use Keystore");
    useKeyStoreValue.setSelected(false);
    useKeyStoreValue.setBounds(5, 60, 200, 19);
    sslPanel.add(useKeyStoreValue);

    useKeyStoreValue.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent acEvent) {
            boolean enabled = useKeyStoreValue.isSelected();
            keyStoreFileNameLabel.setEnabled(enabled);
            keyStoreFileNameValue.setEnabled(enabled);
            keyStorePasswordLabel.setEnabled(enabled);
            keyStorePasswordValue.setEnabled(enabled);
        }
    });

    keyStoreFileNameLabel.setText("Key Store File: ");
    sslPanel.add(keyStoreFileNameLabel);
    keyStoreFileNameLabel.setEnabled(false);
    keyStoreFileNameLabel.setBounds(10, 80, 131, 15);
    sslPanel.add(keyStoreFileNameValue);
    keyStoreFileNameValue.setEnabled(false);
    keyStoreFileNameValue.setBounds(150, 80, 220, 19);
    keyStoreFileNameValue.setFont(GuiFactory.defaultFont);

    keyStorePasswordLabel.setText("Key Store Password: ");
    sslPanel.add(keyStorePasswordLabel);
    keyStorePasswordLabel.setEnabled(false);
    keyStorePasswordLabel.setBounds(10, 110, 131, 15);
    sslPanel.add(keyStorePasswordValue);
    keyStorePasswordValue.setEnabled(false);
    keyStorePasswordValue.setBounds(150, 110, 220, 19);
    keyStorePasswordValue.setFont(GuiFactory.defaultFont);

    add(sslPanel);
    sslPanel.setBounds(10, 355, 450, 140);

    confirmButton.setFont(GuiFactory.defaultFont);
    confirmButton.setText("Save");
    add(confirmButton);
    confirmButton.setBounds(120, 500, 70, 25);
    confirmButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            getValues();
            configPanel.saveDefaultConfig(event.getActionCommand());
            configPanel.finishedDefaultConfig();
        }
    });

    cancelButton.setFont(GuiFactory.defaultFont);
    cancelButton.setText("Cancel");
    add(cancelButton);
    cancelButton.setBounds(200, 500, 70, 25);
    cancelButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            configPanel.finishedDefaultConfig();
        }

    });

    //
    // Setting font...
    //
    Component[] components = getComponents();
    for (int i = 0; (components != null) && (i < components.length); ++i) {
        components[i].setFont(GuiFactory.defaultFont);
    }

    //
    // We add it as the last one so that the font won't be changed
    //
    add(title);
}

From source file:net.sf.jasperreports.customizers.shape.AbstractShapeCustomizer.java

/**
 *
 *///from www .ja  va 2  s .co  m
protected Rectangle2D getBounds(ShapePoints shape) {
    Rectangle2D bounds = null;

    List<Point> points = shape.getPoints();
    if (points != null && !points.isEmpty()) {
        Integer top = null;
        Integer bottom = null;
        Integer left = null;
        Integer right = null;

        for (int i = 0; i < points.size(); i++) {
            Point point = points.get(i);

            if (top == null || point.getY() < top) {
                top = point.getY();
            }

            if (bottom == null || point.getY() > bottom) {
                bottom = point.getY();
            }

            if (left == null || point.getX() < left) {
                left = point.getX();
            }

            if (right == null || point.getX() > right) {
                right = point.getX();
            }
        }

        bounds = new Rectangle(left, top, right - left, bottom - top);
    }

    return bounds;
}

From source file:com.funambol.foundation.admin.SIFSyncSourceConfigPanel.java

/**
 * Create the panel// w ww  .j  a  v  a2 s. c o  m
 *
 * @throws Exception if error occures during creation of the panel
 */
private void init() {
    this.setLayout(null);
    //
    // Set properties of label, position and border referred to the title
    //of the panel
    //
    titledBorder1 = new TitledBorder("");

    panelName.setFont(titlePanelFont);
    panelName.setText("Edit SIF SyncSource");
    panelName.setBounds(new Rectangle(14, 5, 316, 28));
    panelName.setAlignmentX(SwingConstants.CENTER);
    panelName.setBorder(titledBorder1);

    int y = 60;
    int dy = 30;
    int x1 = 14;
    int x2 = 170;
    int w1 = 150;
    int w2 = 350;
    int h = 18;

    sourceUriLabel.setText("Source URI: ");
    sourceUriLabel.setFont(defaultFont);
    sourceUriLabel.setBounds(x1, y, w1, h);
    sourceUriValue.setFont(defaultFont);
    sourceUriValue.setBounds(x2, y, w2, h);

    y += dy;

    nameLabel.setText("Name: ");
    nameLabel.setFont(defaultFont);
    nameLabel.setBounds(x1, y, w1, h);
    nameValue.setFont(defaultFont);
    nameValue.setBounds(x2, y, w2, h);

    y += dy;

    typeLabel.setText("Type: ");
    typeLabel.setFont(defaultFont);
    typeLabel.setBounds(x1, y, w1, h);
    typeCombo.setFont(defaultFont);
    typeCombo.setBounds(x2, y, 100, h);
    typeCombo.addItem(TYPE_SIF_C);
    typeCombo.addItem(TYPE_SIF_E);
    typeCombo.addItem(TYPE_SIF_N);
    typeCombo.addItem(TYPE_SIF_T);

    typeCombo.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            handleTypeSelected();
        }
    });

    handleTypeSelected();

    y += dy;

    directoryLabel.setText("Source Directory: ");
    directoryLabel.setFont(defaultFont);
    directoryLabel.setBounds(x1, y, w1, h);
    directoryValue.setFont(defaultFont);
    directoryValue.setBounds(x2, y, w2, h);

    y += dy;

    twinPropertiesLabel.setText("Twin properties: ");
    twinPropertiesLabel.setFont(defaultFont);
    twinPropertiesLabel.setBounds(x1, y, w1, h);
    descrTwinPropLabel.setText("(Used to identify twins)");
    descrTwinPropLabel.setFont(defaultFont);
    descrTwinPropLabel.setBounds(x1, (y + 15), w1, h);

    twinPropertiesValue.setFont(defaultFont);
    twinPropertiesValue.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    twinPropertiesValue.setAutoscrolls(true);

    scrollTable = new JScrollPane(twinPropertiesValue);
    scrollTable.setWheelScrollingEnabled(true);
    scrollTable.setBounds(x2, y, 200, 66);
    scrollTable.setColumnHeader(null);
    scrollTable.setMinimumSize(new Dimension(200, 66));
    scrollTable.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);

    y += 45;
    y += dy;

    multiUserLabel.setText("MultiUser: ");
    multiUserLabel.setFont(defaultFont);
    multiUserLabel.setBounds(x1, y, w1, h);
    multiUserValue.setSelected(false);
    multiUserValue.setBounds(x2, y, h, h);

    y += 5;
    y += dy;

    confirmButton.setFont(defaultFont);
    confirmButton.setText("Add");
    confirmButton.setBounds(x2, y, 70, 25);
    confirmButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                validateValues();
                getValues();
                if (getState() == STATE_INSERT) {
                    SIFSyncSourceConfigPanel.this.actionPerformed(new ActionEvent(SIFSyncSourceConfigPanel.this,
                            ACTION_EVENT_INSERT, event.getActionCommand()));
                } else {
                    SIFSyncSourceConfigPanel.this.actionPerformed(new ActionEvent(SIFSyncSourceConfigPanel.this,
                            ACTION_EVENT_UPDATE, event.getActionCommand()));
                }
            } catch (Exception e) {
                notifyError(new AdminException(e.getMessage()));
            }
        }
    });

    //
    // Add all components to the panel
    //
    this.add(panelName, null);
    this.add(sourceUriLabel, null);
    this.add(sourceUriValue, null);
    this.add(nameLabel, null);
    this.add(nameValue, null);
    this.add(typeLabel, null);
    this.add(typeCombo, null);
    this.add(directoryLabel, null);
    this.add(directoryValue, null);
    this.add(twinPropertiesLabel, null);
    this.add(scrollTable, null);
    this.add(descrTwinPropLabel, null);
    this.add(multiUserLabel, null);
    this.add(multiUserValue, null);
    this.add(confirmButton, null);
}

From source file:com.funambol.json.admin.CalendarSyncSourceAdminPanel.java

/**
 * Create the panel//from  www  . j  a va  2  s  . c  om
 * @throws Exception if error occures during creation of the panel
 */
private void init() {

    this.setLayout(null);
    // set properties of label, position and border
    //  referred to the title of the panel
    titledBorder = new TitledBorder("");
    panelName.setFont(titlePanelFont);
    panelName.setText(getPanelName());
    panelName.setBounds(new Rectangle(14, 5, 316, 28));
    panelName.setAlignmentX(SwingConstants.CENTER);
    panelName.setBorder(titledBorder);

    final int LABEL_X = 14;
    final int VALUE_X = 170;
    int y = 60;
    final int GAP_X = 150;
    final int GAP_Y = 30;

    sourceUriLabel.setText("Source URI: ");
    sourceUriLabel.setFont(defaultFont);
    sourceUriLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18));
    sourceUriValue.setFont(defaultFont);
    sourceUriValue.setBounds(new Rectangle(VALUE_X, y, 350, 18));

    y += GAP_Y; // New line

    nameLabel.setText("Name: ");
    nameLabel.setFont(defaultFont);
    nameLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18));
    nameValue.setFont(defaultFont);
    nameValue.setBounds(new Rectangle(VALUE_X, y, 350, 18));
    y += GAP_Y; // New line

    typeLabel.setText("Client Type: ");
    typeLabel.setFont(defaultFont);
    typeLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18));
    typeCombo.setFont(defaultFont);
    typeCombo.setBounds(new Rectangle(VALUE_X, y, 350, 18));
    typeCombo.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            updateEntityTypeCheckBoxes();
        }
    });

    y += GAP_Y; // New line

    datastoretypeLabel.setText("Datastore Type: ");
    datastoretypeLabel.setFont(defaultFont);
    datastoretypeLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18));
    datastoretypeCombo.setFont(defaultFont);
    datastoretypeCombo.setBounds(new Rectangle(VALUE_X, y, 350, 18));

    y += GAP_Y; // New line
    int x = LABEL_X;

    y = addExtraComponents(x, y, GAP_X, GAP_Y); // Add other components, if needed

    y += GAP_Y; // New line

    confirmButton.setFont(defaultFont);
    confirmButton.setText("Add");
    confirmButton.setBounds(VALUE_X, y, 70, 25);

    // What happens when the confirmButton is pressed?
    confirmButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            try {
                validateValues();
                getValues();
                if (getState() == STATE_INSERT) {
                    CalendarSyncSourceAdminPanel.this.actionPerformed(new ActionEvent(
                            CalendarSyncSourceAdminPanel.this, ACTION_EVENT_INSERT, event.getActionCommand()));
                } else {
                    CalendarSyncSourceAdminPanel.this.actionPerformed(new ActionEvent(
                            CalendarSyncSourceAdminPanel.this, ACTION_EVENT_UPDATE, event.getActionCommand()));
                }
            } catch (Exception e) {
                notifyError(new AdminException(e.getMessage(), e));
            }
        }
    });

    // Adds all components to the panel
    this.add(panelName, null);
    this.add(nameLabel, null);
    this.add(sourceUriLabel, null);
    this.add(sourceUriValue, null);
    this.add(nameValue, null);
    this.add(typeLabel, null);
    this.add(typeCombo, null);
    this.add(confirmButton, null);
    this.add(eventValue, null);
    this.add(taskValue, null);
    this.add(datastoretypeLabel, null);
    this.add(datastoretypeCombo, null);

}

From source file:dk.i2m.netbeans.modules.ldapexplorer.ui.ExplorerTopComponent.java

/**
 * Event handler for when an {@link LdapEntryNode} is selected.
 *
 * @param ev Event that invoked the handler
 *///from   w w w  . j  a v a2s . c om
public void resultChanged(LookupEvent ev) {

    Collection c = result.allInstances();

    // Get the model of the attribute table
    DefaultTableModel model = (DefaultTableModel) tblAttributes.getModel();
    model.setRowCount(0);

    txtLdif.setText("");

    if (!c.isEmpty()) {
        LdapEntryNode e = (LdapEntryNode) c.iterator().next();

        try {
            // Get the LdapEntry associated with this node
            LdapEntry entry = e.getLookup().lookup(LdapEntry.class);

            // Show LdapEntry if it was found for this node
            // Note: On the root node there is no LdapEntry, hence the check
            if (entry != null) {
                entry = server.getEntry(entry.getDn());
                ldifPane.scrollRectToVisible(new Rectangle(0, 0, 1, 1));
                txtLdif.setText(entry.toLDIF());

                // Add the DN as it is not part of the attributes
                addRow(model, "dn", entry.getDn());

                for (String att : entry.getAttributes().keySet()) {
                    for (Object val : entry.getAttributes().get(att)) {
                        addRow(model, att, val);
                    }
                }
            } else {
                txtLdif.setText("");
            }
        } catch (QueryException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
        }
    }
}