Search in sources :

Example 91 with Dimension

use of java.awt.Dimension in project opennms by OpenNMS.

the class RealUltimateLayoutAlgorithm method updateLayout.

@Override
public void updateLayout(Graph graph) {
    final Layout graphLayout = graph.getLayout();
    SparseGraph<VertexRef, EdgeRef> jungGraph = new SparseGraph<VertexRef, EdgeRef>();
    Collection<? extends Vertex> vertices = graph.getDisplayVertices();
    for (Vertex v : vertices) {
        jungGraph.addVertex(v);
    }
    Collection<? extends Edge> edges = graph.getDisplayEdges();
    for (Edge e : edges) {
        jungGraph.addEdge(e, e.getSource().getVertex(), e.getTarget().getVertex());
    }
    Dimension size = selectLayoutSize(graph);
    Dimension paddedSize = new Dimension((int) (size.getWidth() * .75), (int) (size.getHeight() * .75));
    doISOMLayout(graphLayout, jungGraph, size);
    doSpringLayout(graphLayout, jungGraph, size, SPRING_LAYOUT_REPULSION);
    doFRLayout(graphLayout, jungGraph, paddedSize, (int) (size.getWidth() / 8.0), (int) (size.getHeight() / 8.0));
    doSpringLayout(graphLayout, jungGraph, size, SPRING_LAYOUT_REPULSION);
}
Also used : SparseGraph(edu.uci.ics.jung.graph.SparseGraph) Vertex(org.opennms.features.topology.api.topo.Vertex) NonStupidISOMLayout(org.opennms.features.topology.app.internal.jung.ISOMLayoutAlgorithm.NonStupidISOMLayout) Layout(org.opennms.features.topology.api.Layout) FRLayout(edu.uci.ics.jung.algorithms.layout.FRLayout) SpringLayout(edu.uci.ics.jung.algorithms.layout.SpringLayout) EdgeRef(org.opennms.features.topology.api.topo.EdgeRef) Dimension(java.awt.Dimension) VertexRef(org.opennms.features.topology.api.topo.VertexRef) Edge(org.opennms.features.topology.api.topo.Edge)

Example 92 with Dimension

use of java.awt.Dimension in project zaproxy by zaproxy.

the class AbstractDialog method centreDialog.

/**
	 * Centres this dialog on the main fame.
	 * This is needed, because when using multiple monitors.
	 * Additionally, it will shrink the size of the dialog to fit the screen.
	 */
public void centreDialog() {
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = this.getSize();
    // shrink dialog to fit screen if necessary
    frameSize.height = Math.min(frameSize.height, screenSize.height);
    frameSize.width = Math.min(frameSize.width, screenSize.width);
    // centres the dialog on main frame 
    final Rectangle mainrect = View.getSingleton().getMainFrame().getBounds();
    int x = mainrect.x + (mainrect.width - frameSize.width) / 2;
    int y = mainrect.y + (mainrect.height - frameSize.height) / 2;
    // finally set the new location
    this.setLocation(x, y);
}
Also used : Rectangle(java.awt.Rectangle) Dimension(java.awt.Dimension)

Example 93 with Dimension

use of java.awt.Dimension in project zaproxy by zaproxy.

the class FilterReplaceDialog method initialize.

/**
	 * This method initializes this
	 */
protected void initialize() {
    // ZAP: Changed visibility from private to protected.
    this.setContentPane(getJPanel());
    // ZAP: Added 10 more pixels to the dialog's height
    if (Model.getSingleton().getOptionsParam().getViewParam().getWmUiHandlingOption() == 0) {
        this.setSize(346, 166);
    }
    this.setPreferredSize(new Dimension(346, 166));
    this.pack();
}
Also used : Dimension(java.awt.Dimension)

Example 94 with Dimension

use of java.awt.Dimension in project jdk8u_jdk by JetBrains.

the class BMPCompressionTest method showDiff.

private static void showDiff(final BufferedImage in, final BufferedImage out) {
    final int width = in.getWidth();
    final int height = in.getHeight();
    JFrame f = new JFrame("");
    f.getContentPane().add(new JComponent() {

        public Dimension getPreferredSize() {
            return new Dimension(2 * width + 2, height);
        }

        public void paintComponent(Graphics g) {
            g.setColor(Color.black);
            g.drawImage(in, 0, 0, null);
            g.drawImage(out, width + 2, 0, null);
        }
    });
    f.pack();
    f.setVisible(true);
}
Also used : Graphics(java.awt.Graphics) JFrame(javax.swing.JFrame) JComponent(javax.swing.JComponent) Dimension(java.awt.Dimension)

Example 95 with Dimension

use of java.awt.Dimension in project jdk8u_jdk by JetBrains.

the class bug4337267 method createContentPane.

Component createContentPane() {
    Dimension size = new Dimension(500, 100);
    i1 = new TestBufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB);
    i2 = new TestBufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB);
    p1 = new TestJPanel();
    p1.setPreferredSize(size);
    p2 = new TestJPanel();
    p2.setPreferredSize(size);
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.add(p1);
    panel.add(p2);
    return panel;
}
Also used : JPanel(javax.swing.JPanel) BoxLayout(javax.swing.BoxLayout) Dimension(java.awt.Dimension)

Aggregations

Dimension (java.awt.Dimension)4003 JPanel (javax.swing.JPanel)1091 JLabel (javax.swing.JLabel)742 Point (java.awt.Point)683 JButton (javax.swing.JButton)671 ActionEvent (java.awt.event.ActionEvent)644 ActionListener (java.awt.event.ActionListener)583 JScrollPane (javax.swing.JScrollPane)558 BorderLayout (java.awt.BorderLayout)492 Insets (java.awt.Insets)411 BoxLayout (javax.swing.BoxLayout)334 GridBagLayout (java.awt.GridBagLayout)312 GridBagConstraints (java.awt.GridBagConstraints)266 FlowLayout (java.awt.FlowLayout)242 JTextField (javax.swing.JTextField)235 ImageIcon (javax.swing.ImageIcon)216 Component (java.awt.Component)215 Color (java.awt.Color)205 ChangeEvent (javax.swing.event.ChangeEvent)200 ChangeListener (javax.swing.event.ChangeListener)198