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:org.streamspinner.harmonica.application.CQGraphTerminal.java

/**
 * This method initializes jButton   //from  w  ww  .j a v  a 2 s. co  m
 *    
 * @return javax.swing.JButton   
 */
private JButton getJButton() {
    if (jButton == null) {
        jButton = new JButton();
        jButton.setText("o^");
        jButton.addActionListener(this);
        jButton.setMaximumSize(new Dimension(60, 40));
        jButton.setPreferredSize(new Dimension(60, 40));
        jButton.setBounds(new Rectangle(341, 30, 59, 40));
    }
    return jButton;
}

From source file:de.uni_hannover.dcsec.siafu.model.World.java

/**
 * Instantiate the world in which the simulation will run.
 * // w  w  w  .j  ava2  s.c o  m
 * @param simulation
 *            the simulation object which is running this world.
 * @param simData
 *            the simulation data (maps, sprites, classes) for this
 *            simulation.
 */
public World(final Simulation simulation, final SimulationData simData) {
    this.simulation = simulation;
    this.simData = simData;
    this.simulationConfig = simData.getConfigFile();
    this.worldName = simulationConfig.getString("worldname");
    this.iterationStep = simulationConfig.getInt("iterationstep");

    Agent.resetAgents();

    Controller.getProgress().reportWorldCreation(worldName);

    buildWalls();

    this.defaultFloor = new Floor(new Rectangle(0, 0, this.getWidth(), this.getHeight()), -1);

    createFloors();

    initializeCoordinates();

    createTime();

    createPlaces();

    createPeople();

    freezeInfoFields();

    createOverlays();

}

From source file:TexturedPanel.java

/**
 * Creates a new TexturePaint using the provided image.
 *///from w  ww .  j a  v  a  2s  .co  m
private void setupImagePainter(Image texture) {
    if (texture == null) {
        ourPainter = null;
        return;
    }

    int w = texture.getWidth(this);
    int h = texture.getHeight(this);

    if (w <= 0 || h <= 0) {
        ourPainter = null;
        return;
    }

    BufferedImage buff = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE);

    Graphics2D g2 = buff.createGraphics();
    g2.drawImage(texture, 0, 0, this);
    ourPainter = new TexturePaint(buff, new Rectangle(0, 0, w, h));

    g2.dispose();
}

From source file:EntryLayout.java

/**
 * Lays out the container in the specified panel. This is a row-column type
 * layout; find x, y, width and height of each Component.
 * //from  w w w  .jav a  2s  .  co  m
 * @param parent
 *            The Container whose children we are laying out.
 */
public void layoutContainer(Container parent) {

    if (!validWidths)
        return;
    Component[] components = parent.getComponents();
    Dimension contSize = parent.getSize();
    int x = 0;
    for (int i = 0; i < components.length; i++) {
        int row = i / COLUMNS;
        int col = i % COLUMNS;
        Component c = components[i];
        Dimension d = c.getPreferredSize();
        int colWidth = (int) (contSize.width * widthPercentages[col]);

        if (col == 0) {
            x = hpad;
        } else {
            x += hpad * (col - 1) + (int) (contSize.width * widthPercentages[col - 1]);
        }
        int y = vpad * (row) + (row * heights[row]) + (heights[row] - d.height);
        Rectangle r = new Rectangle(x, y, colWidth, d.height);
        c.setBounds(r);
    }
}

From source file:org.streamspinner.harmonica.application.CQGraphTerminal.java

/**
 * This method initializes jButton1   //from  w  w  w. j a  v  a  2 s  .  c om
 *    
 * @return javax.swing.JButton   
 */
private JButton getJButton1() {
    if (jButton1 == null) {
        jButton1 = new JButton();
        jButton1.setText("Q?");
        jButton1.addActionListener(this);
        jButton1.setMaximumSize(new Dimension(60, 40));
        jButton1.setPreferredSize(new Dimension(60, 40));
        jButton1.setBounds(new Rectangle(341, 80, 59, 40));
    }
    return jButton1;
}

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

/**
 * Create the panel//  www  .  ja  v a 2  s  .  c  o  m
 */

private void init() {
    // set layout
    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 File Data Object SyncSource");
    panelName.setBounds(new Rectangle(14, 5, 316, 28));
    panelName.setAlignmentX(SwingConstants.CENTER);
    panelName.setBorder(titledBorder1);

    int y = 60;
    int dy = 30;

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

    y += dy;

    nameLabel.setText("Name: ");
    nameLabel.setFont(defaultFont);
    nameLabel.setBounds(new Rectangle(14, y, 150, 18));
    nameValue.setFont(defaultFont);
    nameValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;

    storageProviderLabel.setText("Storage type:");
    storageProviderLabel.setFont(defaultFont);
    storageProviderLabel.setBounds(new Rectangle(14, y, 150, 18));
    //list of supported storage providers
    String[] providers = new String[] { PROVIDER_FILESYSTEM, PROVIDER_S3 };
    storageProviderValue = new JComboBox(providers);
    storageProviderValue.addActionListener(jcloudsProviderValueActionListener);
    storageProviderValue.setFont(defaultFont);
    storageProviderValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;

    //    storageContainerNameLabel.setText("Provider container name:");
    storageContainerNameLabel.setFont(defaultFont);
    storageContainerNameLabel.setBounds(new Rectangle(14, y, 150, 18));
    storageContainerNameValue.setFont(defaultFont);
    storageContainerNameValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;

    //    storageIdentityLabel.setText("Provider identity:");
    storageIdentityLabel.setFont(defaultFont);
    storageIdentityLabel.setBounds(new Rectangle(14, y, 150, 18));
    storageIdentityValue.setFont(defaultFont);
    storageIdentityValue.setBounds(new Rectangle(170, y, 350, 18));

    //storage provider identity and storageFilesystemRootPathLabel aren't
    //showed together, so leaving the y coordinate equals the panel has a better
    //aspect for different storage types
    //y += dy;

    //    storageFilesystemRootPathLabel.setText("Local path for filesystem provider:");
    storageFilesystemRootPathLabel.setFont(defaultFont);
    storageFilesystemRootPathLabel.setBounds(new Rectangle(14, y, 150, 18));
    storageFilesystemRootPathValue.setFont(defaultFont);
    storageFilesystemRootPathValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;

    //    storageCredentialLabel.setText("Provider credential:");
    storageCredentialLabel.setFont(defaultFont);
    storageCredentialLabel.setBounds(new Rectangle(14, y, 150, 18));
    storageCredentialValue.setFont(defaultFont);
    storageCredentialValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;

    localRootPathLabel.setText("Root local path for temp files: ");
    localRootPathLabel.setFont(defaultFont);
    localRootPathLabel.setBounds(new Rectangle(14, y, 150, 18));
    localRootPathValue.setFont(defaultFont);
    localRootPathValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;

    quotaLabel.setText("Quota: ");
    quotaLabel.setFont(defaultFont);
    quotaLabel.setBounds(new Rectangle(14, y, 150, 18));
    model = new RolesTableModel();
    quotaTable = new JTable(model);
    quotaTable.setFont(defaultFont);
    quotaTable.setShowGrid(true);
    quotaTable.setAutoscrolls(true);
    quotaTable.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION);
    //add the table into a JScrollPanel, otherwise no columns headers and border
    //will be show
    JScrollPane scrollpane = new JScrollPane(quotaTable);
    scrollpane.setBounds(new Rectangle(170, y, 350, 110));
    quotaTable.setPreferredScrollableViewportSize(new Dimension(350, 110));

    y += dy + 75;
    notaLabel.setText(
            "<html>Please enter the number followed by 'M' if it is 'MegaBytes', or 'G' if it is 'GigaBytes'<BR>Example: '100 M' stands for 100 MegaBytes, '2 G' stands for 2 GigaBytes</html>");
    notaLabel.setFont(defaultFont);
    notaLabel.setBounds(new Rectangle(170, y, 350, 54));

    //button separed from other controls, and the height of the table
    y += dy + 36;

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

    confirmButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                validateValues();
                getValues();
                if (getState() == STATE_INSERT) {
                    FileDataObjectSyncSourceConfigPanel.this
                            .actionPerformed(new ActionEvent(FileDataObjectSyncSourceConfigPanel.this,
                                    ACTION_EVENT_INSERT, event.getActionCommand()));
                } else {
                    FileDataObjectSyncSourceConfigPanel.this
                            .actionPerformed(new ActionEvent(FileDataObjectSyncSourceConfigPanel.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(storageProviderLabel, null);
    this.add(storageProviderValue, null);
    this.add(storageContainerNameLabel, null);
    this.add(storageContainerNameValue, null);
    this.add(storageIdentityLabel, null);
    this.add(storageIdentityValue, null);
    this.add(storageCredentialLabel, null);
    this.add(storageCredentialValue, null);
    this.add(storageFilesystemRootPathLabel, null);
    this.add(storageFilesystemRootPathValue, null);
    this.add(localRootPathLabel, null);
    this.add(localRootPathValue, null);
    this.add(quotaLabel, null);
    this.add(scrollpane, null);
    this.add(notaLabel, null);
    this.add(confirmButton, null);
}

From source file:com.mgmtp.perfload.loadprofiles.ui.ctrl.ConfigController.java

public Rectangle getFrameBounds() {
    try {/* ww w  .  j  av a2  s.co m*/
        int width = Integer.parseInt(getAppProperties().getProperty("frame.width"));
        int height = Integer.parseInt(getAppProperties().getProperty("frame.height"));
        int x = Integer.parseInt(getAppProperties().getProperty("frame.x"));
        int y = Integer.parseInt(getAppProperties().getProperty("frame.y"));
        return new Rectangle(x, y, width, height);
    } catch (NumberFormatException ex) {
        log.warn("Could not read frame bounds from properties. Using defaults.");
        return null;
    }
}

From source file:com.shending.support.CompressPic.java

public static void cut(String srcFile, String dstFile, int widthRange, int heightRange) {
    int x = 0;/*ww  w .ja v  a2 s  .co  m*/
    int y = 0;
    try {
        ImageInputStream iis = ImageIO.createImageInputStream(new File(srcFile));
        Iterator<ImageReader> iterator = ImageIO.getImageReaders(iis);
        ImageReader reader = (ImageReader) iterator.next();
        reader.setInput(iis, true);
        ImageReadParam param = reader.getDefaultReadParam();
        int oldWidth = reader.getWidth(0);
        int oldHeight = reader.getHeight(0);
        int newWidth, newHeight;
        newWidth = oldHeight * widthRange / heightRange;
        if (newWidth < oldWidth) {
            newHeight = oldHeight;
            x = (oldWidth - newWidth) / 2;
        } else {
            newWidth = oldWidth;
            newHeight = oldWidth * heightRange / widthRange;
            y = (oldHeight - newHeight) / 2;
        }
        Rectangle rectangle = new Rectangle(x, y, newWidth, newHeight);
        param.setSourceRegion(rectangle);
        BufferedImage bi = reader.read(0, param);
        File file = new File(dstFile);
        ImageIO.write(bi, reader.getFormatName(), file);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:cc.kune.core.server.manager.file.ImageUtilsDefault.java

/**
 * Crop image.//w  ww  .  j  a v a 2  s .c  o  m
 * 
 * @param fileOrig
 *          the file orig
 * @param fileDest
 *          the file dest
 * @param x
 *          the x
 * @param y
 *          the y
 * @param width
 *          the width
 * @param height
 *          the height
 * @return true, if successful
 * @throws MagickException
 *           the magick exception
 * @throws FileNotFoundException
 *           the file not found exception
 */
public static boolean cropImage(final String fileOrig, final String fileDest, final int x, final int y,
        final int width, final int height) throws MagickException, FileNotFoundException {
    final Rectangle rectangle = new Rectangle(x, y, width, height);
    return cropImage(fileOrig, fileDest, rectangle);
}

From source file:TexturedPanel.java

/**
 * Creates a new TexturePaint using the provided icon.
 */// w w  w.  j  av  a 2 s.  co m
private void setupIconPainter(Icon texture) {
    if (texture == null) {
        ourPainter = null;
        return;
    }

    int w = texture.getIconWidth();
    int h = texture.getIconHeight();

    if (w <= 0 || h <= 0) {
        ourPainter = null;
        return;
    }

    BufferedImage buff = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE);

    Graphics2D g2 = buff.createGraphics();
    texture.paintIcon(this, g2, 0, 0);
    ourPainter = new TexturePaint(buff, new Rectangle(0, 0, w, h));

    g2.dispose();
}