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.opennms.features.topology.app.internal.jung.FRLayoutTest.java

private TopoFRLayout<VertexRef, EdgeRef> runFRLayout(Graph g, Layout graphLayout, List<Vertex> vertices) {
    TopoFRLayout<VertexRef, EdgeRef> layout = new TopoFRLayout<>(createJungGraph(g));
    Dimension size = selectLayoutSize(m_graphContainer);
    //layout.setRepulsionMultiplier(3/8.0);
    //layout.setAttractionMultiplier(3/8.0);
    layout.setInitializer(initializer(graphLayout, size));
    layout.setSize(size);//from   w w  w . j a v a 2 s. c o m

    while (!layout.done()) {
        layout.step();
    }

    LOG.info("/******** FRLayout Run **********/");

    for (Vertex v : vertices) {
        graphLayout.setLocation(v,
                new Point(layout.getX(v) - size.getWidth() / 2.0, layout.getY(v) - size.getHeight() / 2.0));
        LOG.info("layout.getX(): " + layout.getX(v) + " layout.getY(): " + layout.getY(v));
    }
    LOG.info("/******** End FRLayout Run **********/");

    return layout;
}

From source file:com.jswitch.reporte.controlador.JasperViewer2.java

/** This method is called from within the constructor to
 * initialize the form./*from w  w  w. j a v  a 2 s .  c om*/
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
private void initComponents() {//GEN-BEGIN:initComponents
    pnlMain = new javax.swing.JPanel();

    setTitle("JasperViewer");
    setIconImage(
            new javax.swing.ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/jricon.GIF"))
                    .getImage());
    addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosing(java.awt.event.WindowEvent evt) {
            exitForm();
        }
    });

    pnlMain.setLayout(new java.awt.BorderLayout());

    getContentPane().add(pnlMain, java.awt.BorderLayout.CENTER);

    pack();

    Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit();
    java.awt.Dimension screenSize = toolkit.getScreenSize();
    int screenResolution = toolkit.getScreenResolution();
    float zoom = ((float) screenResolution) / JRViewer.REPORT_RESOLUTION;

    int height = (int) (550 * zoom);
    if (height > screenSize.getHeight()) {
        height = (int) screenSize.getHeight();
    }
    int width = (int) (750 * zoom);
    if (width > screenSize.getWidth()) {
        width = (int) screenSize.getWidth();
    }

    java.awt.Dimension dimension = new java.awt.Dimension(width, height);
    setSize(dimension);
    setLocation((screenSize.width - width) / 2, (screenSize.height - height) / 2);
}

From source file:vn.topmedia.monitor.form.MDIMain.java

/**
 * Creates new form MDIMain// w w  w. j  a  v a  2s.  c o m
 */
public MDIMain() {
    initComponents();
    initConfigure();
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    this.setSize((int) d.getWidth(), (int) d.getHeight());
}

From source file:org.apache.joshua.ui.tree_visualizer.DerivationTreeTransformer.java

public DerivationTreeTransformer(DerivationTree t, Dimension d, boolean isAnchored) {
    this.isAnchored = isAnchored;
    anchorPoint = new Point2D.Double(0, 0);
    graph = t;/*from   w  ww  . j  ava2 s .  c  om*/
    DelegateForest<Node, DerivationTreeEdge> del = new DelegateForest<Node, DerivationTreeEdge>(t);
    del.setRoot(t.root);
    del.setRoot(t.sourceRoot);
    root = t.root;
    sourceRoot = t.sourceRoot;
    Y_DIST = d.getHeight() / (2 * (1 + distanceToLeaf(root)));
    int leafCount = 0;
    for (Node n : t.getVertices()) {
        if (t.outDegree(n) == 0)
            leafCount++;
    }
    X_DIST = d.getWidth() / leafCount;

    treeLayout = new TreeLayout<Node, DerivationTreeEdge>(del, (int) Math.round(X_DIST));
}

From source file:net.lmxm.ute.preferences.AbstractPreferences.java

/**
 * Sets the dimension.//from www .  j a va 2 s .  co m
 * 
 * @param key the key
 * @param dimension the dimension
 */
protected final void setDimension(final String key, final Dimension dimension) {
    final String prefix = "setDimension() :";

    LOGGER.debug("{} entered, key={}", prefix, key);

    if (dimension == null) {
        LOGGER.debug("{} dimension is null, returning without setting", prefix);

        return;
    }

    setInt(key + HEIGHT_SUFFIX, (int) dimension.getHeight());
    setInt(key + WIDTH_SUFFIX, (int) dimension.getWidth());

    LOGGER.debug("{} leaving", prefix);
}

From source file:codes.thischwa.c5c.DispatcherPUT.java

private void imageProcessingAndSizeCheck(Path tempPath, String sanitizedName, long fileSize,
        FilemanagerConfig conf) throws C5CException, IOException {
    Integer maxSize = (conf.getUpload().isFileSizeLimitAuto()) ? PropertiesLoader.getMaxUploadSize()
            : conf.getUpload().getFileSizeLimit();
    if (fileSize > maxSize.longValue() * 1024 * 1024)
        throw new FilemanagerException(FilemanagerAction.UPLOAD,
                FilemanagerException.Key.UploadFilesSmallerThan, String.valueOf(maxSize));
    String extension = FilenameUtils.getExtension(sanitizedName);

    // check image only
    boolean isImageExt = checkImageExtension(sanitizedName, conf.getUpload().isImagesOnly(),
            conf.getImages().getExtensions());
    if (!isImageExt)
        return;/* ww  w.  jav  a 2s  . c  o m*/

    // remove exif data
    Path woExifPath = UserObjectProxy.removeExif(tempPath);
    if (!tempPath.equals(woExifPath)) {
        Files.move(woExifPath, tempPath, StandardCopyOption.REPLACE_EXISTING);
    }

    // check if the file is really an image
    InputStream in = new BufferedInputStream(Files.newInputStream(tempPath, StandardOpenOption.READ));
    Dimension dim = getDimension(in);
    if (isImageExt && dim == null)
        throw new FilemanagerException(FilemanagerAction.UPLOAD, FilemanagerException.Key.UploadImagesOnly);
    IOUtils.closeQuietly(in);

    // check if resize is enabled and fix it, if necessary 
    Resize resize = conf.getImages().getResize();
    if (resize.isEnabled()
            && (dim.getHeight() > resize.getMaxHeight() || dim.getWidth() > resize.getMaxWidth())) {
        logger.debug("process resize");
        StreamContent sc = connector.resize(new BufferedInputStream(Files.newInputStream(tempPath)), extension,
                new Dimension(resize.getMaxWidth(), resize.getMaxHeight()));
        Files.copy(sc.getInputStream(), tempPath, StandardCopyOption.REPLACE_EXISTING);
        IOUtils.closeQuietly(sc.getInputStream());
    }
}

From source file:org.photovault.swingui.JAIPhotoViewer.java

/**
 Finds the best instance of the current photo and shows it. The instance is 
 selected so that it needs as little postprocessing as possible. Hovewer, the 
 operations in {@link dynOps} must not be preapplied in the instance since 
 these may be changing during viewing of the image.
         /*from   w  w  w .  j  a v  a 2s  .c o m*/
 */
private void showBestInstance() throws PhotovaultException {
    EnumSet<ImageOperations> allowedOps = EnumSet.allOf(ImageOperations.class);
    allowedOps.removeAll(dynOps);
    int w = imageView.getWidth();
    int h = imageView.getHeight();
    Dimension croppedSize = photo.getCroppedSize();
    double ar = croppedSize.getWidth() / croppedSize.getHeight();
    if (w > ar * h) {
        w = (int) (h * ar);
    } else {
        h = (int) (w / ar);
    }
    ImageDescriptorBase image = photo.getPreferredImage(EnumSet.noneOf(ImageOperations.class), allowedOps, w, h,
            Integer.MAX_VALUE, Integer.MAX_VALUE);
    if (image != null && image.getLocator().equals("image#0")) {
        File imageFile = image.getFile().findAvailableCopy();
        if (imageFile != null && imageFile.canRead()) {
            // TODO: is this really needed?
            String fname = imageFile.getName();
            int lastDotPos = fname.lastIndexOf(".");
            if (lastDotPos <= 0 || lastDotPos >= fname.length() - 1) {
                // TODO: error handling needs thinking!!!!
                // throw new IOException( "Cannot determine file type extension of " + imageFile.getAbsolutePath() );
                fireViewChangeEvent();
                return;
            }
            PhotovaultImageFactory imageFactory = new PhotovaultImageFactory();
            PhotovaultImage img = null;
            try {
                /*
                 Do not read the image yet since setting raw conversion
                 parameters later may force a re-read.
                 */
                img = imageFactory.create(imageFile, false, false);
            } catch (PhotovaultException ex) {
                final JAIPhotoViewer component = this;
                final String msg = ex.getMessage();
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(component, msg, "Error loading file",
                                JOptionPane.ERROR_MESSAGE);
                    }
                });
            }
            if (img != null) {
                appliedOps = EnumSet.noneOf(ImageOperations.class);
                if (rawImage != null) {
                    rawImage.removeChangeListener(this);
                }
                if (img instanceof RawImage) {
                    rawImage = (RawImage) img;
                    rawImage.setRawSettings(
                            localRawSettings != null ? localRawSettings : photo.getRawSettings());
                    rawImage.addChangeListener(this);
                    // Check the correct resolution for this image
                    if (isFit) {
                        fit();
                    } else {
                        setScale(getScale());
                    }
                } else {
                    rawImage = null;
                    rawConvScaling = 1.0f;
                }
            }
            if (image instanceof CopyImageDescriptor) {
                // This is a copy, so it may be cropped already
                appliedOps = ((CopyImageDescriptor) image).getAppliedOperations();
                if (!appliedOps.contains(ImageOperations.COLOR_MAP)) {
                    img.setColorAdjustment(
                            localChanMap != null ? localChanMap : photo.getColorChannelMapping());
                }
                if (!appliedOps.contains(ImageOperations.CROP)) {
                    instanceRotation = ((CopyImageDescriptor) image).getRotation();
                    double rot = photo.getPrefRotation() - instanceRotation;
                    imageView.setRotation(rot);
                    imageView.setCrop(photo.getCropBounds());
                }
            } else {
                // This is original so we must apply corrections
                img.setColorAdjustment(localChanMap != null ? localChanMap : photo.getColorChannelMapping());
                imageView.setRotation(photo.getPrefRotation());
                imageView.setCrop(photo.getCropBounds());
            }
            setImage(img);
            fireViewChangeEvent();
            return;
        }
    }
    // if we get this far no instance of the original image has been found
    setImage(null);
    throw new PhotovaultException("No suitable instance of photo " + photo.getUuid() + " found");

}

From source file:joshua.ui.tree_visualizer.DerivationTreeTransformer.java

public DerivationTreeTransformer(DerivationTree t, Dimension d, boolean isAnchored) {
    this.isAnchored = isAnchored;
    anchorPoint = new Point2D.Double(0, 0);
    graph = t;/*  ww  w  . jav a 2s.  c o  m*/
    DelegateForest<Node, DerivationTreeEdge> del = new DelegateForest<Node, DerivationTreeEdge>(t);
    del.setRoot(t.getRoot());
    del.setRoot(t.getSourceRoot());
    root = t.getRoot();
    sourceRoot = t.getSourceRoot();
    Y_DIST = d.getHeight() / (2 * (1 + distanceToLeaf(root)));
    int leafCount = 0;
    for (Node n : t.getVertices()) {
        if (t.outDegree(n) == 0)
            leafCount++;
    }
    X_DIST = d.getWidth() / leafCount;

    treeLayout = new TreeLayout<Node, DerivationTreeEdge>(del, (int) Math.round(X_DIST));
}

From source file:eu.europa.esig.dss.pdf.pdfbox.PdfBoxSignatureService.java

private void fillImageParameters(final PDDocument doc, final SignatureImageParameters imgParams,
        SignatureOptions options) throws IOException {
    Dimension optimalSize = ImageFactory.getOptimalSize(imgParams);
    PDVisibleSignDesigner visibleSig = new PDVisibleSignDesigner(doc, ImageFactory.create(imgParams),
            imgParams.getPage());//from   w  ww . j  a  va2  s .co m
    visibleSig.xAxis(imgParams.getxAxis()).yAxis(imgParams.getyAxis()).width((float) optimalSize.getWidth())
            .height((float) optimalSize.getHeight());

    PDVisibleSigProperties signatureProperties = new PDVisibleSigProperties();
    signatureProperties.visualSignEnabled(true).setPdVisibleSignature(visibleSig).buildSignature();

    options.setVisualSignature(signatureProperties);
    options.setPage(imgParams.getPage());
}

From source file:org.richfaces.component.InputNumberSliderComponentTest.java

public void testArrowsImages() throws Exception {
    InternetResource image;/*w w  w.  j  av a 2  s. c  o m*/
    Dimension imageDim;
    image = InternetResourceBuilder.getInstance().createResource(null,
            SliderTrackGradientVertical.class.getName());
    imageDim = ((Java2Dresource) image).getDimensions(facesContext, null);
    assertTrue(imageDim.getWidth() == 7 && imageDim.getHeight() == 10);

    image = InternetResourceBuilder.getInstance().createResource(null, SliderArrowImageLeft.class.getName());
    imageDim = ((Java2Dresource) image).getDimensions(facesContext, null);
    assertTrue(imageDim.getWidth() == 7 && imageDim.getHeight() == 8);

    image = InternetResourceBuilder.getInstance().createResource(null, SliderArrowImageRight.class.getName());
    imageDim = ((Java2Dresource) image).getDimensions(facesContext, null);
    assertTrue(imageDim.getWidth() == 7 && imageDim.getHeight() == 8);

    image = InternetResourceBuilder.getInstance().createResource(null, SliderArrowImageTop.class.getName());
    imageDim = ((Java2Dresource) image).getDimensions(facesContext, null);
    assertTrue(imageDim.getWidth() == 7 && imageDim.getHeight() == 8);

    image = InternetResourceBuilder.getInstance().createResource(null,
            SliderArrowSelectedImageLeft.class.getName());
    imageDim = ((Java2Dresource) image).getDimensions(facesContext, null);
    assertTrue(imageDim.getWidth() == 7 && imageDim.getHeight() == 8);

    image = InternetResourceBuilder.getInstance().createResource(null,
            SliderArrowSelectedImageRight.class.getName());
    imageDim = ((Java2Dresource) image).getDimensions(facesContext, null);
    assertTrue(imageDim.getWidth() == 7 && imageDim.getHeight() == 8);

    image = InternetResourceBuilder.getInstance().createResource(null,
            SliderArrowSelectedImageTop.class.getName());
    imageDim = ((Java2Dresource) image).getDimensions(facesContext, null);
    assertTrue(imageDim.getWidth() == 7 && imageDim.getHeight() == 8);
}