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:view.TimelinePanel.java

/**
 * Creates new form TimelinePanel//from   w ww  .  j av a  2s.  c  o  m
 */
public TimelinePanel() {
    initComponents();

    fxPanel = new JFXPanel();
    final Dimension size = new Dimension(960, 750);
    fxPanel.setSize(size);
    setLayout(new BorderLayout(0, 0));
    add(fxPanel);

    Platform.runLater(new Runnable() { // this will run initFX as JavaFX-Thread
        @Override
        public void run() {
            Group group = new Group();
            Scene scene = new Scene(group);
            fxPanel.setScene(scene);

            WebView webView = new WebView();

            group.getChildren().add(webView);
            webView.setMinSize(size.getWidth(), size.getHeight());
            webView.setMaxSize(size.getWidth(), size.getHeight());

            WebEngine webEngine = webView.getEngine();
            webEngine.load(
                    "http://cdn.knightlab.com/libs/timeline/latest/embed/index.html?source=0Ag1_iE674IuvdEFaZi0wOVBFY2l2OHdPUWlrZEMwaHc&font=Bevan-PotanoSans&maptype=toner&lang=en");
        }
    });
}

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 av a2 s . com*/
 * 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:coreferenceresolver.gui.MarkupGUI.java

private JScrollPane newReviewPanel(Review review, int reviewId) throws BadLocationException {
    //Model//w w  w  .ja  va2  s .  co  m
    ReviewElement reviewElement = new ReviewElement();

    ScrollablePanel reviewPanel = new ScrollablePanel();
    reviewPanel.setLayout(new BoxLayout(reviewPanel, BoxLayout.PAGE_AXIS));

    JTextField title = new JTextField("NEW REVIEW " + reviewId);
    title.setBackground(Color.pink);

    reviewPanel.add(title);

    JTextArea reviewContentTxtArea = new JTextArea();
    reviewContentTxtArea.setLineWrap(true);
    reviewContentTxtArea.setWrapStyleWord(true);
    reviewContentTxtArea.setEditable(false);
    reviewContentTxtArea.setText(review.getRawContent());

    int chainId = 0;
    for (CorefChain cc : review.getCorefChains()) {
        for (int npId : cc.getChain()) {
            NounPhrase np = review.getNounPhrases().get(npId);
            Object highlighTag = reviewContentTxtArea.getHighlighter().addHighlight(np.getOffsetBegin(),
                    np.getOffsetEnd() + 1, highlightPainters.get(chainId));
            this.markupReviews.get(reviewId).getNounPhrases().get(npId).highlighterTag = highlighTag;
        }
        ++chainId;
    }

    reviewPanel.add(reviewContentTxtArea);

    ScrollablePanel markupsPanel = new ScrollablePanel();
    markupsPanel.setLayout(new BoxLayout(markupsPanel, BoxLayout.PAGE_AXIS));

    for (int i = 0; i < review.getNounPhrases().size(); ++i) {
        JScrollPane newMarkupPanel = newMarkupPanel(review.getNounPhrases().get(i), reviewElement);
        markupsPanel.add(newMarkupPanel);
    }

    JScrollPane scrollMarkupsPanel = new JScrollPane(markupsPanel);

    //Add Dimension for scrolling
    Dimension curScreenDimen = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    scrollMarkupsPanel.setPreferredSize(new Dimension((int) curScreenDimen.getWidth() - 50, 400));

    reviewPanel.add(scrollMarkupsPanel);

    //MODEL
    reviewElement.reviewTextArea = reviewContentTxtArea;
    reviewElements.add(reviewElement);

    reviewPanel.add(new JSeparator(SwingConstants.HORIZONTAL));

    reviewPanel.add(Box.createVerticalStrut(20));

    JScrollPane scrollReviewPanel = new JScrollPane(reviewPanel);

    return scrollReviewPanel;
}

From source file:org.zaproxy.zap.extension.callgraph.CallGraphFrame.java

private void setupFrame() {
    // define a visual layout on the graph
    mxHierarchicalLayout layout = new com.mxgraph.layout.hierarchical.mxHierarchicalLayout(graph,
            SwingConstants.WEST);

    final mxGraphComponent graphComponent = new mxGraphComponent(graph);
    graphComponent.setConnectable(false);
    graphComponent.setToolTips(true);/*from   www  .  j  av  a 2s. c o  m*/
    graphComponent.setAutoExtend(true);
    graphComponent.setAutoScroll(true);

    // add the graph component to the frame in the centre.
    getContentPane().add(graphComponent, BorderLayout.CENTER);

    // and set up a panel below that
    JPanel toolBar = new JPanel();
    toolBar.setLayout(new BorderLayout());
    // with an outline of the graph, and have it settle in the west..
    final mxGraphOutline graphOutline = new mxGraphOutline(graphComponent);
    graphOutline.setPreferredSize(new Dimension(100, 100));
    toolBar.add(graphOutline, BorderLayout.WEST);

    // and some buttons in the panel
    JPanel buttonBar = new JPanel();
    buttonBar.setLayout(new FlowLayout());

    // zoom to fit button
    JButton btZoomToFit = new JButton(Constant.messages.getString("callgraph.button.zoomfit"));
    btZoomToFit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            double newScale = 1;
            Dimension graphSize = graphComponent.getGraphControl().getSize();
            Dimension viewPortSize = graphComponent.getViewport().getSize();
            int gw = (int) graphSize.getWidth();
            int gh = (int) graphSize.getHeight();
            if (gw > 0 && gh > 0) {
                int w = (int) viewPortSize.getWidth();
                int h = (int) viewPortSize.getHeight();

                newScale = Math.min((double) w / gw, (double) h / gh);
            }
            graphComponent.zoomTo(newScale, true);
        }
    });
    buttonBar.add(btZoomToFit);

    // center graph
    JButton btCenter = new JButton(Constant.messages.getString("callgraph.button.centregraph"));
    btCenter.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            Dimension graphSize = graphComponent.getGraphControl().getSize();
            Dimension viewPortSize = graphComponent.getViewport().getSize();
            int x = graphSize.width / 2 - viewPortSize.width / 2;
            int y = graphSize.height / 2 - viewPortSize.height / 2;
            int w = viewPortSize.width;
            int h = viewPortSize.height;
            graphComponent.getGraphControl().scrollRectToVisible(new Rectangle(x, y, w, h));
        }
    });
    buttonBar.add(btCenter);

    // add a rubberband zoom on the mouse selection event
    new mxRubberband(graphComponent) {

        public void mouseReleased(MouseEvent e) {
            // get bounds before they are reset
            Rectangle rect = bounds;
            // invoke usual behaviour
            super.mouseReleased(e);

            if (rect != null) {

                double newScale = 1;
                Dimension graphSize = new Dimension(rect.width, rect.height);
                Dimension viewPortSize = graphComponent.getViewport().getSize();
                int gw = (int) graphSize.getWidth();
                int gh = (int) graphSize.getHeight();
                if (gw > 0 && gh > 0) {
                    int w = (int) viewPortSize.getWidth();
                    int h = (int) viewPortSize.getHeight();
                    newScale = Math.min((double) w / gw, (double) h / gh);
                }
                // zoom to fit the selected area on screen
                graphComponent.zoom(newScale);
                // make the selected area visible
                graphComponent.getGraphControl()
                        .scrollRectToVisible(new Rectangle((int) (rect.x * newScale), (int) (rect.y * newScale),
                                (int) (rect.width * newScale), (int) (rect.height * newScale)));
            }
        }
    };

    // put the components on frame
    toolBar.add(buttonBar, BorderLayout.CENTER);
    getContentPane().add(toolBar, BorderLayout.SOUTH);

    // TODO: Do we need this here?
    // frame.setVisible(true);

    // lay it out
    graph.getModel().beginUpdate();
    try {
        layout.execute(graph.getDefaultParent());
    } finally {
        graph.getModel().endUpdate();
    }

    // setDefaultCloseOperation(JFrame.);
    // setSize(400, 400);
    pack();
    setVisible(true);
}

From source file:de.xplib.xdbm.ui.Application.java

/**
 * /*from   w w w.ja v a2  s .  c  om*/
 */
private void initUI() {

    this.getContentPane().setLayout(new DockLayout(this, DockLayout.STACKING_STYLE));

    this.menuBar = new ApplicationMenuBar(this);
    this.toolBars = new ApplicationToolBars(this);
    this.consolePanel = new BottomFrame(this);
    this.treePanel = new LeftFrame(this);
    this.resourceFrame = new CenterFrame(this);

    this.jspContentConsole = new UIFSplitPane();
    this.jspTreeResource = new UIFSplitPane();

    this.add(this.jspContentConsole, DockLayout.center);

    this.jspContentConsole.setBorder(BorderFactory.createEmptyBorder());
    this.jspContentConsole.setOrientation(JSplitPane.VERTICAL_SPLIT);
    this.jspContentConsole.setDividerSize(5);
    this.jspContentConsole.add(this.jspTreeResource, JSplitPane.TOP);
    this.jspContentConsole.add(this.consolePanel, JSplitPane.BOTTOM);

    this.jspTreeResource.setBorder(BorderFactory.createEmptyBorder());
    this.jspTreeResource.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
    this.jspTreeResource.setDividerSize(5);
    this.jspTreeResource.setDividerLocation(200);
    this.jspTreeResource.add(this.treePanel, JSplitPane.TOP);
    this.jspTreeResource.add(this.resourceFrame, JSplitPane.BOTTOM);

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

    this.setSize((int) dim.getWidth(), (int) dim.getHeight() - 30);
    this.setVisible(true);
}

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

public JFRoomPayment(final JFRoom jfRoom) {
    this.jfRoom = jfRoom;
    this.invoiceController = new InvoiceController();
    invoiceStatusController = new InvoiceStatusController();
    invoiceItemController = new InvoiceItemController();
    roomStatusController = new RoomStatusController();
    this.roomStatusEnabled = roomStatusController.selectEnabled();
    this.statusBillToCompany = invoiceStatusController.selectBillToCompany();
    this.initComponents();
    final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    this.setLocation((int) (screenSize.getWidth() / 2 - 350), (int) (screenSize.getHeight() / 2 - 350));
    this.setModal(true);
    this.setInvoiceStatusModel();
    this.jcbAccountState.setEnabled(false);
}

From source file:tpp.TPPFrame.java

/**
 * This method initializes this/*from www  .  ja v  a  2s.c o  m*/
 * 
 */
private void initialize() {
    this.setJMenuBar(getBar());
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    this.setLocation((int) (screenSize.getWidth() - DEFAULT_DIMENSION.getWidth()) / 2,
            (int) (screenSize.getHeight() - DEFAULT_DIMENSION.getHeight()) / 2);
    this.setSize(DEFAULT_DIMENSION);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setVisible(true);
}

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

protected Transformer<VertexRef, Point2D> initializer(final Layout graphLayout, final Dimension dim) {
    return new Transformer<VertexRef, Point2D>() {
        @Override/*from w  w  w .j av  a 2  s. com*/
        public Point2D transform(VertexRef v) {
            if (v == null) {
                LOG.info("Algorithm tried to layout a null vertex");
                return new java.awt.Point(0, 0);
            }
            org.opennms.features.topology.api.Point location = graphLayout.getLocation(v);
            return new Point2D.Double(location.getX() + dim.getWidth() / 2.0,
                    location.getY() + dim.getHeight() / 2.0);
        }
    };
}

From source file:org.echocat.velma.dialogs.AboutDialog.java

@Nonnull
@Override//  ww w.  j a v a  2 s  .co m
protected Container createContainer() {
    return new JPanel() {
        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            final Graphics2D g2d = (Graphics2D) g;
            final Dimension size = getSize();
            g2d.setRenderingHint(KEY_INTERPOLATION, VALUE_INTERPOLATION_BILINEAR);
            g2d.setRenderingHint(KEY_RENDERING, VALUE_RENDER_QUALITY);
            g2d.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON);
            final double sourceWidth = _backgroundImage.getWidth();
            final double sourceHeight = _backgroundImage.getHeight();
            final double targetWidth = size.getWidth();
            final double targetHeight = size.getHeight();
            final double relWidth = sourceWidth / targetWidth;
            final double relHeight = sourceHeight / targetHeight;
            final double width;
            final double height;
            final double x;
            final double y;
            if (relWidth > relHeight) {
                width = sourceWidth / relHeight;
                height = sourceHeight / relHeight;
                x = ((targetWidth - width) / 2);
                y = 0;
            } else {
                width = sourceWidth / relWidth;
                height = sourceHeight / relWidth;
                x = 0;
                y = ((targetHeight - height) / 2);
            }

            g2d.drawImage(_backgroundImage, (int) x, (int) y, (int) width, (int) height, this);
        }
    };
}

From source file:edu.wustl.xipHost.application.Application.java

public Rectangle getApplicationPreferredSize() {
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Rectangle rect = new Rectangle();
    logger.debug("Screen width: " + new Double(screenSize.getWidth()).intValue());
    logger.debug("Screen height: " + new Double(screenSize.getHeight()).intValue());
    rect.setWidth(new Double(screenSize.getWidth()).intValue());
    rect.setHeight(new Double(screenSize.getHeight()).intValue());
    return rect;/*from w  w  w  . j  a v a 2  s  . c  om*/
}