Example usage for java.awt Dimension getWidth

List of usage examples for java.awt Dimension getWidth

Introduction

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

Prototype

public double getWidth() 

Source Link

Usage

From source file:org.nekorp.workflow.desktop.servicio.imp.ImageServiceImp.java

@Override
public BufferedImage resizeToStandarSize(BufferedImage image) {
    Dimension boundary = new Dimension(imageWidth, imageHeight);
    Dimension originalDimension = new Dimension(image.getWidth(), image.getHeight());
    Dimension newDimension = ImageServiceImp.getScaledDimension(originalDimension, boundary);
    ResampleOp resampleOp = new ResampleOp((int) newDimension.getWidth(), (int) newDimension.getHeight());
    resampleOp.setUnsharpenMask(AdvancedResizeOp.UnsharpenMask.Normal);
    BufferedImage rescaled = resampleOp.filter(image, null);
    return rescaled;
}

From source file:org.nekorp.workflow.desktop.servicio.imp.ImageServiceImp.java

@Override
public BufferedImage getThumbnail(BufferedImage image) {
    Dimension boundary = new Dimension(thumbWidth, thumbHeight);
    Dimension originalDimension = new Dimension(image.getWidth(), image.getHeight());
    Dimension newDimension = ImageServiceImp.getScaledDimension(originalDimension, boundary);
    ResampleOp resampleOp = new ResampleOp((int) newDimension.getWidth(), (int) newDimension.getHeight());
    resampleOp.setUnsharpenMask(AdvancedResizeOp.UnsharpenMask.Normal);
    BufferedImage rescaled = resampleOp.filter(image, null);
    return rescaled;
}

From source file:CenterLayout.java

/**
 * Returns the preferred size./* w ww. j a v a2s .  com*/
 * 
 * @param parent
 *          the parent.
 * 
 * @return the preferred size.
 */
public Dimension preferredLayoutSize(final Container parent) {

    synchronized (parent.getTreeLock()) {
        final Insets insets = parent.getInsets();
        if (parent.getComponentCount() > 0) {
            final Component component = parent.getComponent(0);
            final Dimension d = component.getPreferredSize();
            return new Dimension((int) d.getWidth() + insets.left + insets.right,
                    (int) d.getHeight() + insets.top + insets.bottom);
        } else {
            return new Dimension(insets.left + insets.right, insets.top + insets.bottom);
        }
    }

}

From source file:ArrowPanel.java

/**
 * Paints the arrow panel.//ww  w.jav  a 2s. c  o m
 * 
 * @param g
 *          the graphics device for drawing on.
 */
public void paintComponent(final Graphics g) {

    super.paintComponent(g);
    final Graphics2D g2 = (Graphics2D) g;

    // first determine the size of the drawing area...
    final Dimension size = getSize();
    final Insets insets = getInsets();
    this.available.setRect(insets.left, insets.top, size.getWidth() - insets.left - insets.right,
            size.getHeight() - insets.top - insets.bottom);
    g2.translate(insets.left, insets.top);
    g2.fill(getArrow(this.type));

}

From source file:mupomat.view.PodrskaLozinka.java

private void centrirajZaslon() {
    Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (int) ((dimension.getWidth() - this.getWidth()) / 2);
    int y = (int) ((dimension.getHeight() - this.getHeight()) / 2);
    this.setLocation(x, y);
    this.setResizable(false);
}

From source file:org.jfree.chart.demo.DrawStringPanel.java

public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D graphics2d = (Graphics2D) g;
    Dimension dimension = getSize();
    Insets insets = getInsets();//from w  w w  . ja  va 2s.  c  o  m
    java.awt.geom.Rectangle2D.Double double1 = new java.awt.geom.Rectangle2D.Double(insets.left, insets.top,
            dimension.getWidth() - (double) insets.left - (double) insets.right,
            dimension.getHeight() - (double) insets.top - (double) insets.bottom);
    double d = double1.getCenterX();
    double d1 = double1.getCenterY();
    java.awt.geom.Line2D.Double double2 = new java.awt.geom.Line2D.Double(d - 2D, d1 + 2D, d + 2D, d1 - 2D);
    java.awt.geom.Line2D.Double double3 = new java.awt.geom.Line2D.Double(d - 2D, d1 - 2D, d + 2D, d1 + 2D);
    graphics2d.setPaint(Color.red);
    graphics2d.draw(double2);
    graphics2d.draw(double3);
    graphics2d.setFont(font);
    graphics2d.setPaint(Color.black);
    if (rotate)
        TextUtilities.drawRotatedString(text, graphics2d, (float) d, (float) d1, anchor, angle, rotationAnchor);
    else
        TextUtilities.drawAlignedString(text, graphics2d, (float) d, (float) d1, anchor);
}

From source file:org.pentaho.reporting.engine.classic.extensions.modules.sbarcodes.BarcodeWrapper.java

public void draw(final Graphics2D g2, final Rectangle2D bounds) {
    final Graphics2D gr2 = (Graphics2D) g2.create();
    try {/* www  .  j  ava2 s  . c o m*/
        gr2.clip(bounds);
        if (scale) {
            final Dimension size = barcode.getPreferredSize();
            final double horzScale = bounds.getWidth() / size.getWidth();
            final double vertScale = bounds.getHeight() / size.getHeight();
            if (keepAspectRatio) {
                final double scale = Math.min(horzScale, vertScale);
                gr2.scale(scale, scale);
            } else {
                gr2.scale(horzScale, vertScale);
            }
        }
        barcode.draw(gr2, (int) bounds.getX(), (int) bounds.getY());
    } catch (OutputException e) {
        logger.error("Unable to draw barcode element", e);
    } finally {
        gr2.dispose();
    }

}

From source file:PaintSample.java

/**
 * Fills the component with the current Paint.
 *
 * @param g  the graphics device.//  www  .  ja  v  a 2s .  c  om
 */
public void paintComponent(final Graphics g) {

    final Graphics2D g2 = (Graphics2D) g;
    final Dimension size = getSize();
    final Insets insets = getInsets();
    final double xx = insets.left;
    final double yy = insets.top;
    final double ww = size.getWidth() - insets.left - insets.right - 1;
    final double hh = size.getHeight() - insets.top - insets.bottom - 1;
    final Rectangle2D area = new Rectangle2D.Double(xx, yy, ww, hh);
    g2.setPaint(this.paint);
    g2.fill(area);
    g2.setPaint(Color.black);
    g2.draw(area);

}

From source file:GUI.ResponseStatistics.java

/** * Creates a sample dataset */

private void InitPieChart(JFreeChart chart) {
    ChartPanel chartPanel = new ChartPanel(chart);
    // default size
    chartPanel.setSize(560, 800);/*from   w  w  w  . j av  a 2 s  .co  m*/

    Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (int) ((dimension.getWidth() - chartPanel.getWidth()) / 2);
    int y = (int) ((dimension.getHeight() - chartPanel.getHeight()) / 2);

    chartPanel.setLocation(WIDTH, WIDTH);
    // add it to our application
    setContentPane(chartPanel);

    chartPanel.addChartMouseListener(new ChartMouseListener() {

        public void chartMouseClicked(ChartMouseEvent e) {

            wait = false;

        }

        public void chartMouseMoved(ChartMouseEvent e) {
        }

    });
}

From source file:jflowmap.JFlowMapApplet.java

@Override
public void init() {
    try {//from   w  ww.  j av a  2s.c  o  m
        Container parent;

        JFlowMapAppletFrame frame = new JFlowMapAppletFrame(this);

        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        frame.setSize((int) (screenSize.getWidth() * 0.8), (int) (screenSize.getHeight() * 0.8));
        SwingUtils.centerOnScreen(frame);
        parent = frame.getContentPane();
        createUI(parent);
        frame.setVisible(true);

    } catch (Exception ex) {
        logger.error(ex);
        JMsgPane.showProblemDialog(JFlowMapApplet.this, ex);
    }
}