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:Visualizer.FRWeightedLayout.java

private void doInit() {
    Graph<Functionality.Node, Functionality.Edge> graph = getGraph();
    Dimension d = getSize();
    if (graph != null && d != null) {
        currentIteration = 0;//w ww.j a  v  a 2  s  .  c  o m
        temperature = d.getWidth() / 10;

        forceConstant = Math.sqrt(d.getHeight() * d.getWidth() / graph.getVertexCount());

        attraction_constant = attraction_multiplier * forceConstant;
        repulsion_constant = repulsion_multiplier * forceConstant;
    }
}

From source file:net.sf.jasperreports.view.JasperDesignViewer.java

/** This method is called from within the constructor to
 * initialize the form.//from  w  ww  .j a va 2 s.  co  m
 * 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("JasperDesignViewer");
    setIconImage(
            new javax.swing.ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/jricon.GIF"))
                    .getImage());
    addWindowListener(new java.awt.event.WindowAdapter() {
        @Override
        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) / net.sf.jasperreports.swing.JRViewerPanel.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:com.projity.pm.graphic.chart.TimeChartPanel.java

public void updateTimeScaleComponentSize() {
    Dimension dmain = viewport.getViewSize();

    if (dmain.equals(olddmain))
        return;/*from  w w w. j  a  v a  2 s.c  om*/
    olddmain = dmain;
    Dimension d = chartInfo.getAxisPanel().getPreferredSize();
    d.setSize(d.getWidth(), dmain.getHeight());
    chartInfo.getAxisPanel().revalidate();
}

From source file:KjellDirdalNotepad.java

public void setNormalSize() {
    JScrollPane scrollPane = getScrollPane();
    int x = 0;/* ww w. j  ava 2  s  .  c om*/
    int y = 0;
    Insets scrollInsets = getScrollPaneInsets();

    if (scrollPane != null) {
        Dimension d = scrollPane.getVisibleRect().getSize();
        if (scrollPane.getBorder() != null) {
            d.setSize(d.getWidth() - scrollInsets.left - scrollInsets.right,
                    d.getHeight() - scrollInsets.top - scrollInsets.bottom);
        }

        d.setSize(d.getWidth() - 20, d.getHeight() - 20);
        desktop.setAllSize(x, y);
        scrollPane.invalidate();
        scrollPane.validate();
    }
}

From source file:org.bigwiv.blastgraph.gui.graphvisualization.EWLayout.java

private void doInit() {
    Graph<V, E> graph = getGraph();
    Dimension d = getSize();

    if (graph != null && d != null) {
        currentIteration = 0;//from   w ww .j  a va  2  s .c o  m
        temperature = d.getWidth() / 10;

        forceConstant = Math.sqrt(d.getHeight() * d.getWidth() / graph.getVertexCount());

        attraction_constant = attraction_multiplier * forceConstant;
        repulsion_constant = repulsion_multiplier * forceConstant;
    }
}

From source file:StrokeChooserPanel.java

/**
 * Draws a line using the sample stroke.
 *
 * @param g  the graphics device.//from w w  w .j a  v a2  s  .c  o  m
 */
public void paintComponent(final Graphics g) {

    final Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    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;
    final double hh = size.getHeight() - insets.top - insets.bottom;

    // calculate point one
    final Point2D one = new Point2D.Double(xx + 6, yy + hh / 2);
    // calculate point two
    final Point2D two = new Point2D.Double(xx + ww - 6, yy + hh / 2);
    // draw a circle at point one
    final Ellipse2D circle1 = new Ellipse2D.Double(one.getX() - 5, one.getY() - 5, 10, 10);
    final Ellipse2D circle2 = new Ellipse2D.Double(two.getX() - 6, two.getY() - 5, 10, 10);

    // draw a circle at point two
    g2.draw(circle1);
    g2.fill(circle1);
    g2.draw(circle2);
    g2.fill(circle2);

    // draw a line connecting the points
    final Line2D line = new Line2D.Double(one, two);
    if (this.stroke != null) {
        g2.setStroke(this.stroke);
        g2.draw(line);
    }

}

From source file:jdroidremote.ServerFrame.java

public void initEventDriven() {
    jbtRunServer.addActionListener(new ActionListener() {
        @Override/*from   ww w . jav  a  2 s .  c  o m*/
        public void actionPerformed(ActionEvent e) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        serverSocket = new ServerSocket(5005);
                        System.out.println("Server is running...");
                        clientSocket = serverSocket.accept();
                        dis = new DataInputStream(clientSocket.getInputStream());
                        dos = new DataOutputStream(clientSocket.getOutputStream());
                        System.out.println(
                                "some device connected us from address: " + clientSocket.getInetAddress());

                        thReceiveMouseCoords.start();
                        thStartMonitoring.start();

                    } catch (IOException ex) {
                        Logger.getLogger(ServerFrame.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }).start();

            thReceiveMouseCoords = new Thread(new Runnable() {
                @Override
                public void run() {

                    System.out.println("START RECEIVING COORDS.............");

                    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
                    double width = screenSize.getWidth();
                    double height = screenSize.getHeight();

                    while (1 == 1) {
                        try {
                            String receivedStr = dis.readUTF();

                            if (receivedStr.contains("left_click")) {
                                robot.mousePress(KeyEvent.BUTTON1_DOWN_MASK);
                                robot.mouseRelease(KeyEvent.BUTTON1_DOWN_MASK);
                            } else if (receivedStr.contains("right_click")) {
                                robot.mousePress(KeyEvent.BUTTON3_DOWN_MASK);
                                robot.mouseRelease(KeyEvent.BUTTON3_DOWN_MASK);
                            } else if (receivedStr.contains("coords")) {
                                System.out.println(receivedStr);
                                String[] mouseCoords = receivedStr.split(":");

                                int x = (int) (Integer.parseInt(mouseCoords[0]) * width / 100);
                                int y = (int) (Integer.parseInt(mouseCoords[1]) * height / 100);

                                robot.mouseMove(x, y);
                            } else {
                                String[] dataArr = receivedStr.split("-");

                                typeCharacter(dataArr[1]);
                            }
                        } catch (IOException ex) {
                            Logger.getLogger(ServerFrame.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    }
                }
            });
        }
    });
}

From source file:org.jamwiki.parser.image.ImageUtil.java

/**
 * Determine the scaled dimensions, rounded to an increment for performance reasons,
 * given a max width and height.  For example, if the original dimensions are 800x400,
 * the max width height are 200, and the increment is 400, the result is 400x200.
 *//*www  .  j av a 2  s  .  co m*/
private static Dimension calculateIncrementalDimensions(WikiImage wikiImage, Dimension originalDimensions,
        Dimension scaledDimensions, WikiFileVersion fileVersion) throws IOException {
    int increment = Environment.getIntValue(Environment.PROP_IMAGE_RESIZE_INCREMENT);
    // use width for incremental resizing
    int incrementalWidth = calculateImageIncrement(scaledDimensions.getWidth());
    if (increment <= 0 || incrementalWidth >= originalDimensions.getWidth()) {
        // let the browser scale the image
        return originalDimensions;
    }
    int incrementalHeight = (int) Math
            .round(((double) incrementalWidth / (double) originalDimensions.getWidth())
                    * (double) originalDimensions.getHeight());
    if (isImagesOnFS()) {
        return calculateIncrementalDimensionsForImageFile(wikiImage, originalDimensions, incrementalWidth,
                incrementalHeight);
    } else {
        return calculateIncrementalDimensionsForImageBlob(wikiImage, incrementalWidth, incrementalHeight,
                fileVersion);
    }
}

From source file:KjellDirdalNotepad.java

protected void resizeDesktop() {
    int x = 0;/*from  w  w  w  .j a  v a 2s  . c o m*/
    int y = 0;
    JScrollPane scrollPane = getScrollPane();
    Insets scrollInsets = getScrollPaneInsets();

    if (scrollPane != null) {
        JInternalFrame allFrames[] = desktop.getAllFrames();
        for (int i = 0; i < allFrames.length; i++) {
            if (allFrames[i].getX() + allFrames[i].getWidth() > x) {
                x = allFrames[i].getX() + allFrames[i].getWidth();
            }
            if (allFrames[i].getY() + allFrames[i].getHeight() > y) {
                y = allFrames[i].getY() + allFrames[i].getHeight();
            }
        }
        Dimension d = scrollPane.getVisibleRect().getSize();
        if (scrollPane.getBorder() != null) {
            d.setSize(d.getWidth() - scrollInsets.left - scrollInsets.right,
                    d.getHeight() - scrollInsets.top - scrollInsets.bottom);
        }

        if (x <= d.getWidth())
            x = ((int) d.getWidth()) - 20;
        if (y <= d.getHeight())
            y = ((int) d.getHeight()) - 20;
        desktop.setAllSize(x, y);
        scrollPane.invalidate();
        scrollPane.validate();
    }
}

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

/** This method is called from within the constructor to
 * initialize the form./* w w  w. j  a  v  a 2 s  . c  o  m*/
 * 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);
}