Example usage for java.awt Dimension getHeight

List of usage examples for java.awt Dimension getHeight

Introduction

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

Prototype

public double getHeight() 

Source Link

Usage

From source file:org.opennms.features.topology.app.internal.jung.D3LayoutTest.java

private D3TopoLayout<VertexRef, EdgeRef> runD3Layout(int count, Graph g, Layout graphLayout,
        List<Vertex> vertices) throws IOException {
    D3TopoLayout<VertexRef, EdgeRef> layout = new D3TopoLayout<>(createJungGraph(g));
    Dimension size = selectLayoutSize(m_graphContainer);

    layout.setInitializer(initializer(graphLayout, size));
    layout.setSize(size);/*from  w ww.  j ava2s. c om*/

    try (PrintWriter out = new PrintWriter(new FileWriter("target/data" + count + ".js"))) {
        out.println("var gCenter = { x: " + size.getWidth() / 2.0 + ", y: " + size.getHeight() / 2.0 + "};");
        out.println("var data = [");
        while (!layout.done()) {
            out.println("[");

            for (int i = 0; i < vertices.size(); i++) {
                Vertex v = vertices.get(i);
                if (i + 1 == vertices.size()) {
                    out.println("{ x:" + layout.getX(v) + ", y:" + layout.getY(v) + " }");
                } else {
                    out.println("{ x:" + layout.getX(v) + ", y:" + layout.getY(v) + " },");
                }
            }

            layout.step();
            out.println("],");
        }
        out.println("];");
        LOG.info("/******** D3Layout 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 D3Layout Run **********/");
    return layout;
}

From source file:org.jannocessor.ui.RenderPreviewDialog.java

private void initialize() {
    logger.debug("Initializing UI...");
    DefaultSyntaxKit.initKit();//from   w ww .j a v a  2s .co m

    JEditorPane.registerEditorKitForContentType("text/java_template", "org.jannocessor.syntax.JavaTemplateKit",
            getClass().getClassLoader());

    JEditorPane.registerEditorKitForContentType("text/java_output", "org.jannocessor.syntax.JavaOutputKit",
            getClass().getClassLoader());

    setTitle("JAnnocessor - Java Annotation Processor");
    setLayout(new BorderLayout(5, 5));

    listFiles();

    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension screenSize = tk.getScreenSize();
    double width = screenSize.getWidth() * 0.9;
    double height = screenSize.getHeight() * 0.8;

    // Font font = new Font("Courier New", Font.PLAIN, 14);

    input = createInput();
    JScrollPane scroll1 = new JScrollPane(input, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    input.setContentType("text/java_template");

    input.setText("");

    scroll1.setMinimumSize(new Dimension(200, 200));
    scroll1.setPreferredSize(new Dimension((int) (width * 0.5), (int) height));
    add(scroll1, BorderLayout.CENTER);

    output = Box.createVerticalBox();

    scroll2 = new JScrollPane(output, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scroll2.setMinimumSize(new Dimension(200, 200));
    scroll2.setPreferredSize(new Dimension((int) (width * 0.5), (int) height));
    add(scroll2, BorderLayout.EAST);

    combo = createCombo();

    combo.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            load((File) combo.getSelectedItem());
        }
    });

    add(combo, BorderLayout.NORTH);
    JLabel help = new JLabel(
            " Choose a template from the drop-down box to edit it. Navigation: Alt + Left & Alt + Right; Refresh = F5, Close = Esc",
            JLabel.CENTER);

    help.setForeground(Color.WHITE);
    help.setBackground(Color.BLACK);
    help.setOpaque(true);
    help.setFont(new Font("Courier New", Font.BOLD, 14));
    add(help, BorderLayout.SOUTH);

    keyListener = new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_F5) {
                e.consume();
                processElements();
                refresh();
            } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                e.consume();
                dispose();
            } else if (e.getKeyCode() == KeyEvent.VK_LEFT && e.isAltDown()) {
                e.consume();
                moveBackward();
            } else if (e.getKeyCode() == KeyEvent.VK_RIGHT && e.isAltDown()) {
                e.consume();
                moveForward();
            } else if (e.getKeyCode() == KeyEvent.VK_S && e.isControlDown()) {
                e.consume();
                save();
            } else if (e.getKeyCode() == KeyEvent.VK_I && e.isControlDown()) {
                e.consume();
                increase();
            } else if (e.getKeyCode() == KeyEvent.VK_D && e.isControlDown()) {
                e.consume();
                decrease();
            }
        }
    };

    input.addKeyListener(keyListener);
    combo.addKeyListener(keyListener);

    setActive(0);

    pack();
    setModal(true);
    setLocationRelativeTo(null);
    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

    input.requestFocus();
    logger.debug("Initialized UI.");
}

From source file:InterfaceGrafica.java

/**
 * ler a topologia da memria secundria e desenha o grfico
 *///  ww w.  j a va  2s . com
private void adicionaGrafico(String[][] nodesConnections) {
    DirectedSparseGraph g = new DirectedSparseGraph();

    int numeroEdge = 0;
    for (String[] connection : nodesConnections) {
        if (!g.containsVertex(connection[0])) {
            g.addVertex(connection[0]);
        }
        if (!g.containsVertex(connection[1])) {
            g.addVertex(connection[1]);
        }
        g.addEdge(Integer.toString(numeroEdge), connection[0], connection[1]);
        numeroEdge++;
    }

    Transformer<String, String> transformer = (String arg) -> arg;

    Dimension dimension = graficoPanel.getSize();
    VisualizationViewer visualizationViewer = new VisualizationViewer(new CircleLayout(g),
            new Dimension((int) dimension.getWidth(), (int) (dimension.getHeight() * HEIGHT_REDIMENSION)));
    visualizationViewer.setBackground(Color.WHITE);
    visualizationViewer.getRenderContext().setVertexLabelTransformer(transformer);
    graficoPanel.setLayout(new BorderLayout());
    graficoPanel.add(visualizationViewer);
    graficoPanel.revalidate();
}

From source file:org.esa.nest.dat.views.polarview.PolarCanvas.java

private Rectangle positionPlot(Dimension size, int x, int y, int bottom, int right) {
    //insets.setValue(top, left, bottom, right);
    //Rectangle r = insets.shrinkRect(size);
    final Rectangle r = new Rectangle(x, y, (int) size.getWidth() - x - right,
            (int) size.getHeight() - y - bottom);
    origin = r.getLocation();/*from www  . j  av  a 2 s  .  co  m*/
    graphSize.setSize(r.width, r.height);
    return r;
}

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

public void testImages() throws Exception {
    InternetResource image = InternetResourceBuilder.getInstance().createResource(null,
            SliderFieldGradient.class.getName());
    Dimension imageDim = ((Java2Dresource) image).getDimensions(facesContext, null);
    assertTrue(imageDim.getWidth() == 31 && imageDim.getHeight() == 55);

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

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

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

From source file:press.gfw.Windows.java

private void initWindows() {

    Dimension dimemsion = Toolkit.getDefaultToolkit().getScreenSize();

    setSize(480, 270);//from w w w . ja  v a  2s .  c o  m

    setLocation((int) (dimemsion.getWidth() - getWidth()) / 2, (int) (dimemsion.getHeight() - getHeight()) / 2);

    // setAlwaysOnTop(true);

    setResizable(false);

    addWindowListener(new WindowsListener());

    // ?
    BorderLayout windowsLayout = new BorderLayout(20, 20);

    setLayout(windowsLayout);

}

From source file:jfix.zk.Mediafield.java

public Mediafield() {
    setHflex("1");
    upload.addEventListener(Events.ON_UPLOAD, $event -> uploadPerformed(((UploadEvent) $event).getMedia()));
    download.addEventListener(Events.ON_CLICK, $event -> downloadPerformed());
    rotateImage.addEventListener(Events.ON_CLICK, $event -> {
        try {//from  w  ww  . jav  a 2  s . com
            File imageFile = Medias.asFile(media);
            imageFile.deleteOnExit();
            File rotatedImage = jfix.util.Images.rotate(imageFile);
            rotatedImage.deleteOnExit();
            setMedia(media.getName(), media.getContentType(), rotatedImage);
        } catch (IOException e) {
            Modal.exception(e);
        }

    });

    aspectRatioLock.setChecked(true);
    EventListener<Event> dimensionChanged = $event -> {
        Dimension scaledDimension = null;
        if (aspectRatioLock.isChecked()) {
            scaledDimension = jfix.util.Images.scaleDimension(originalDimension,
                    new Dimension(width.intValue(), height.intValue()));
            width.setValue((int) scaledDimension.getWidth());
            height.setValue((int) scaledDimension.getHeight());
        } else {
            scaledDimension = new Dimension(width.intValue(), height.intValue());
        }
        File imageFile = Medias.asFile(media);
        imageFile.deleteOnExit();
        File scaledImage = jfix.util.Images.scale(imageFile, scaledDimension);
        scaledImage.deleteOnExit();
        setMedia(media.getName(), media.getContentType(), scaledImage);
    };
    width.addEventListener(Events.ON_CHANGE, dimensionChanged);
    height.addEventListener(Events.ON_CHANGE, dimensionChanged);

    setHeight("300px");
    setPreview(true);
    codemirror.setVisible(false);
    imagePreview.setVisible(false);
    width.setStep(10);
    height.setStep(10);

    download.setImage(Images.DriveRemovableMedia);
    download.setVisible(false);

    appendChild(codemirror);
    appendChild(imagePreview);
    appendChild(new Row(download, upload));
}

From source file:nl.b3p.viewer.print.PrintInfo.java

public void cacheLegendImagesAndReadDimensions() {
    for (Legend l : legendUrls) {
        for (LegendPart lp : l.getLegendParts()) {
            File legendFile = null;
            InputStream in = null;
            ByteArrayOutputStream legendMemoryCache = new ByteArrayOutputStream();
            FileOutputStream fos = null;
            try {
                log.debug("Loading legend from URL: " + lp.getUrl());
                URL u = new URL(lp.getUrl());
                in = u.openStream();//ww w . j  a va  2  s .co m
                IOUtils.copy(in, legendMemoryCache);

                legendFile = File.createTempFile("legend_img_", null);
                tempFiles.add(legendFile);
                legendFile.deleteOnExit();
                fos = new FileOutputStream(legendFile);
                IOUtils.copy(new ByteArrayInputStream(legendMemoryCache.toByteArray()), fos);
                fos.flush();
                lp.setUrl(legendFile.toURI().toString());
                log.debug("Legend part url changed to point to temporary file: " + lp.getUrl());

                Dimension dim = getImageDimension(new ByteArrayInputStream(legendMemoryCache.toByteArray()));
                if (dim == null) {
                    log.debug("No dimensions could be determined");
                } else {
                    lp.setWidth((int) dim.getWidth());
                    lp.setHeight((int) dim.getHeight());
                    log.debug(String.format("Dimensions: %d x %d", lp.getWidth(), lp.getHeight()));
                }

            } catch (Exception e) {
                log.warn("Exception loading legend dimensions from URL " + lp.getUrl(), e);
            } finally {
                if (in != null) {
                    try {
                        in.close();
                    } catch (IOException ex) {
                    }
                }
                if (fos != null) {
                    try {
                        fos.close();
                    } catch (IOException ex) {
                    }
                }
            }
        }
    }
}

From source file:util.StreamBlobUtil.java

/**
* Returns scaled blob/*from w  ww . j  a va  2  s .  c om*/
* @param b byte stream
* @param width width of the image
* @param height height of the image
* @param scale boolean yes or no
* @return scaled byte stream
*/
public synchronized byte[] newStreamBlob(byte[] b, int width, int height, boolean doIScale)
        throws BasicObjException {

    logger.info("entered 1 streamBlob");
    if (b == null) {
        return null;
    }
    logger.info("entered 2 streamBlob");
    try {
        initializeImageInfo();
        logger.info("completed new ImageInfo()");
        if (info != null) {
            logger.info("info != null");
            //MagickImage image = new MagickImage(info, b);
            logger.info("completed new MagickImage() in streamBlob");
            if (image != null) {
                image.blobToImage(info, b);
                MagickImage scaled = null;
                if (doIScale) {
                    // scale the image
                    Dimension d = image.getDimension();
                    logger.info("completed new getDimension() in streamBlob");
                    d = WebUtil.getDimension(d, width, height);
                    logger.info("completed getDimension() in streamBlob");
                    if (d != null) {
                        scaled = image.scaleImage((int) d.getWidth(), (int) d.getHeight());
                    }
                } else {
                    // don't scale the image
                    scaled = image.scaleImage(width, height);
                }
                if (scaled != null) {
                    logger.info("completing 4 streamBlob");
                    return (scaled.imageToBlob(info));
                }
            }
        }
    } catch (Exception e) {
        throw new BasicObjException("Error writing image stream ", e);
    }
    logger.info("returning null in streamBlob");
    return null;
}

From source file:co.com.soinsoftware.hotelero.view.JFRoomDetail.java

public JFRoomDetail(final JFRoom parent, final InvoiceController invoiceController) throws IOException {
    this.initComponents();
    final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    this.setLocation((int) (screenSize.getWidth() / 2 - 350), (int) (screenSize.getHeight() / 2 - 380));
    this.setModal(true);
    this.parent = parent;
    this.invoiceController = invoiceController;
    roomStatusController = new RoomStatusController();
    invoiceStatusController = new InvoiceStatusController();
    this.roomStatusBooked = roomStatusController.selectBooked();
}