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.jtrfp.trcl.obj.ProjectileFactory.java

public ProjectileFactory(TR tr, Weapon weapon, ExplosionType explosionType) {
    this.tr = tr;
    this.weapon = weapon;
    this.projectileSpeed = weapon.getSpeed() / TR.crossPlatformScalar;
    Model modelToUse;//from  w  w w.  j av  a  2  s .  com
    TextureDescription t;
    Triangle[] tris;
    final int damageOnImpact = weapon.getDamage();
    try {
        modelToUse = new Model(false, tr);
        final ModelingType modelingType = weapon.getModelingType();
        if (modelingType instanceof ModelingType.FlatModelingType) {
            ModelingType.FlatModelingType mt = (ModelingType.FlatModelingType) modelingType;
            Dimension dims = mt.getSegmentSize();
            final int laserplaneLength = (int) (dims.getWidth() / TR.crossPlatformScalar);
            final int laserplaneWidth = (int) (dims.getHeight() / TR.crossPlatformScalar);
            t = tr.getResourceManager()
                    .getRAWAsTexture(tr.config.getGameVersion() != GameVersion.TV ? mt.getF3RawFileName()
                            : mt.getTvRawFileName(), tr.getDarkIsClearPaletteVL(), null, false);
            final double Y_SLANT = 1024;
            tris = (Triangle.quad2Triangles(
                    new double[] { -laserplaneLength / 2., laserplaneLength / 2., laserplaneLength / 2.,
                            -laserplaneLength / 2. }, //X
                    new double[] { 0, 0, Y_SLANT, Y_SLANT },
                    new double[] { -laserplaneWidth / 2., -laserplaneWidth / 2., laserplaneWidth / 2.,
                            laserplaneWidth / 2. }, //YZ
                    new double[] { 1, 0, 0, 1 }, new double[] { 0, 0, 1, 1 }, t, RenderMode.STATIC,
                    Vector3D.ZERO, "ProjectileFactory:" + weapon.toString()));//UVtr
            tris[0].setAlphaBlended(true);
            tris[1].setAlphaBlended(true);
            modelToUse.addTriangles(tris);
            modelToUse.finalizeModel();
            for (int i = 0; i < projectiles.length; i++) {
                projectiles[i] = new ProjectileObject3D(tr, modelToUse, weapon, explosionType);
            }
        } //end if(isLaser)
        else if (modelingType instanceof ModelingType.BillboardModelingType) {
            final ModelingType.BillboardModelingType mt = (ModelingType.BillboardModelingType) modelingType;
            final Texture[] frames = new Texture[mt.getRawFileNames().length];
            final String[] fileNames = mt.getRawFileNames();
            final ResourceManager mgr = tr.getResourceManager();
            final ColorPaletteVectorList pal = tr.getGlobalPaletteVL();
            GL3 gl = tr.gpu.get().getGl();
            for (int i = 0; i < frames.length; i++) {
                frames[i] = (Texture) mgr.getRAWAsTexture(fileNames[i], pal, null, false);
            } //end for(frames)
            TextureDescription tex = new AnimatedTexture(
                    new Sequencer(mt.getTimeInMillisPerFrame(), frames.length, false), frames);
            for (int i = 0; i < projectiles.length; i++) {
                projectiles[i] = new ProjectileBillboard(tr, weapon, tex, ExplosionType.Billow);
            }
        } //end (billboard)
        else if (modelingType instanceof ModelingType.BINModelingType) {
            final ModelingType.BINModelingType mt = (ModelingType.BINModelingType) modelingType;
            modelToUse = tr.getResourceManager().getBINModel(mt.getBinFileName(), tr.getGlobalPaletteVL(), null,
                    tr.gpu.get().getGl());
            for (int i = 0; i < projectiles.length; i++) {
                projectiles[i] = new ProjectileObject3D(tr, modelToUse, weapon, explosionType);
            }
        } //end BIN Modeling Type
        else {
            throw new RuntimeException("Unhandled ModelingType: " + modelingType.getClass().getName());
        }
    } //end try
    catch (Exception e) {
        e.printStackTrace();
    }
    //CLAUSE: FFF needs destroysEvertyhing behavior
    if (weapon == Weapon.DAM) {
        for (int i = 0; i < projectiles.length; i++) {
            ((WorldObject) projectiles[i]).addBehavior(new DestroysEverythingBehavior());
        }
    } //end if(DAM)

    //Sound
    String soundFile = null;
    switch (weapon) {
    //PEW!!!
    case PAC: {
        soundFile = "LASER2.WAV";
        break;
    }
    case ION: {
        soundFile = "LASER3.WAV";
        break;
    }
    case RTL: {
        soundFile = "LASER4.WAV";
        break;
    }
    case DAM:
    case redLaser:
    case blueLaser:
    case greenLaser:
    case purpleLaser:
    case purpleRing: {
        soundFile = "LASER5.WAV";
        break;
    }
    //Missile
    case enemyMissile:
    case SWT:
    case MAM:
    case SAD: {
        soundFile = "MISSILE.WAV";
        break;
    }
    //SILENT
    case purpleBall:
    case goldBall:
    case fireBall:
    case blueFireBall:
    case bullet:
    case bossW8:
    case bossW7:
    case bossW6:
    case atomWeapon:
    default:
        break;
    }//end case()
    soundTexture = soundFile != null ? tr.getResourceManager().soundTextures.get(soundFile) : null;
}

From source file:ireport_5_6_0.view.JasperDesignViewer.java

/** This method is called from within the constructor to
 * initialize the form.//ww  w.j  a  v  a 2s.  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("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) / 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:esmska.gui.AboutFrame.java

private void licenseButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_licenseButtonActionPerformed
    //show licence
    try {/*from  w  w  w.ja v  a  2 s  .co m*/
        logger.fine("Showing license...");
        String license = IOUtils.toString(getClass().getResourceAsStream(RES + "license.txt"), "UTF-8");
        final String agpl = IOUtils.toString(getClass().getResourceAsStream(RES + "gnu-agpl.txt"), "UTF-8");
        license = MiscUtils.escapeHtml(license);
        license = license.replaceAll("GNU Affero General Public License",
                "<a href=\"agpl\">GNU Affero General Public License</a>");

        final JTextPane tp = new JTextPane();
        tp.setContentType("text/html; charset=UTF-8");
        tp.setText("<html><pre>" + license + "</pre></html>");
        tp.setEditable(false);
        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
        tp.setPreferredSize(new Dimension((int) d.getWidth() / 2, (int) d.getHeight() / 2)); //reasonable size
        tp.setCaretPosition(0);
        //make links clickable
        tp.addHyperlinkListener(new HyperlinkListener() {
            @Override
            public void hyperlinkUpdate(final HyperlinkEvent e) {
                if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                    logger.fine("Showing GNU AGPL...");
                    tp.setText(null);
                    tp.setContentType("text/plain");
                    tp.setText(agpl);
                    tp.setCaretPosition(0);
                }
            }
        });

        String option = l10n.getString("AboutFrame.Acknowledge");
        JOptionPane op = new JOptionPane(new JScrollPane(tp), JOptionPane.INFORMATION_MESSAGE,
                JOptionPane.DEFAULT_OPTION, null, new Object[] { option }, option);
        JDialog dialog = op.createDialog(this, l10n.getString("AboutFrame.License"));
        dialog.setResizable(true);
        dialog.pack();
        dialog.setVisible(true);
    } catch (IOException ex) {
        logger.log(Level.WARNING, "Could not show license", ex);
    }
}

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  ww w . j av  a 2s  .co  m
    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:de.mpg.mpi_inf.bioinf.netanalyzer.ui.ChartDisplayPanel.java

/**
 * Creates a Swing control that displays this panel's chart.
 * <p>//  w w w. j  a v a2  s  . co  m
 * The newly created panel is stored in the {@link #chartPanel} field.
 * </p>
 * 
 * @return The newly created panel instance that displays the chart.
 */
private JPanel createChartPanel() {
    chartPanel = JFreeChartConn.createPanel(chart);
    Dimension size = chartPanel.getPreferredSize();
    size.setSize(size.getWidth() / 3 * 2, size.getHeight() / 3 * 2);
    chartPanel.setPreferredSize(size);
    return chartPanel;
}

From source file:graphic.ihm.dialog.createperso.DialCreatePerso.java

/**
 * @param evt// w w  w .j av a 2 s  .  c  o m
 */
private void cancelActionPerformed(ActionEvent evt) {
    MainMenu menu = new MainMenu(null, false);
    Dimension tailleEcran = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    menu.setLocation((int) (tailleEcran.getWidth() / 2 - menu.getWidth() / 2),
            (int) (tailleEcran.getHeight() / 2 - menu.getHeight() / 2));
    menu.setVisible(true);
    this.setVisible(false);
}

From source file:edu.uci.ics.jung.algorithms.layout.FRLayout.java

private void doInit() {
    Graph<V, E> graph = getGraph();
    Dimension d = getSize();
    if (graph != null && d != null) {
        currentIteration = 0;//  w w w.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:Main.java

public void componentMoved(ComponentEvent evt) {
    if (locked)/*from  w ww  .  j  av  a 2 s.c  om*/
        return;
    Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
    int nx = evt.getComponent().getX();
    int ny = evt.getComponent().getY();
    // top
    if (ny < 0 + sd) {
        ny = 0;
    }
    // left
    if (nx < 0 + sd) {
        nx = 0;
    }
    // right
    if (nx > size.getWidth() - evt.getComponent().getWidth() - sd) {
        nx = (int) size.getWidth() - evt.getComponent().getWidth();
    }
    // bottom
    if (ny > size.getHeight() - evt.getComponent().getHeight() - sd) {
        ny = (int) size.getHeight() - evt.getComponent().getHeight();
    }
    locked = true;
    evt.getComponent().setLocation(nx, ny);
    locked = false;
}

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;//  www  .  j  a  v  a2s.  c  om
    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:com.mc.printer.model.StartTask.java

@Override
public void onSucceeded(Object object) {
    if (object instanceof Exception) {
        Exception e = (Exception) object;
        logger.error(e.getMessage());/*from   w w  w. j  a v  a2  s.c o m*/
    }
    if (AutoPrinterApp.isRegister) {
        logger.info("connect to remote server,please wait...");
    }
    new FileTask(FileTask.TYPE_DOWNLOAD, ClientConstants.GUIDE_DOWNLOAD_DIR, "") {

        @Override
        public void responseResult(String file) {

            if (AutoPrinterApp.isRegister) {
                /*video*/
                new FileTask(FileTask.TYPE_DOWNLOAD, ClientConstants.VIDEO_LIB, "video") {
                    @Override
                    public void responseResult(String file) {
                        logger.info("download video task completed.>" + ClientConstants.VIDEO_LIB);
                    }
                }.execute();
            } else {
                logger.debug("client has not register, can't fetch the video.");
            }

            final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            final int maxWidth = (int) screenSize.getWidth();
            final int maxHeight = (int) Math.round(screenSize.getHeight() / 3); //??1/3
            logger.info("load application completed. try to open guide and form...");

            new BaseTask() {
                @Override
                public Object doBackgrounp() {
                    new OpenGuidePaperTask(Constants.GUIDE_BOTTOM_FILE) {
                        @Override
                        public void onSucceed(Object object, HashMap<String, Integer> statusMap) {

                            if (object == null || object instanceof Exception) {
                                topRealHeight = maxHeight;
                            } else if (object instanceof GuideBean) {
                                GuideBean guideBean = (GuideBean) object;
                                GuidePanel panel = new GuidePanel(null, guideBean, maxWidth,
                                        guideBean.getHeight()) {

                                    @Override
                                    public GuidePanel parentGuideWindow() {
                                        return null;
                                    }

                                    @Override
                                    public GuidePanel targetWindowAfterAuth() {
                                        return null;
                                    }
                                };
                                panel.enableButtonByRemote(statusMap);
                                AutoPrinterApp.getClientMain().setBottomUI(panel);
                                topRealHeight = panel.getCurrentGuideBean().getHeight();
                            }

                        }
                    }.run();

                    new OpenGuidePaperTask(Constants.GUIDE_TOP_FILE) {
                        @Override
                        public void onSucceed(Object object, HashMap<String, Integer> statusMap) {
                            if (object == null || object instanceof Exception) {
                                bottomRealHeight = maxHeight;
                            } else if (object instanceof GuideBean) {

                                GuideBean guideBean = (GuideBean) object;
                                GuidePanel panel = new GuidePanel(null, guideBean, maxWidth,
                                        guideBean.getHeight()) {
                                    @Override
                                    public GuidePanel parentGuideWindow() {
                                        return null;
                                    }

                                    @Override
                                    public GuidePanel targetWindowAfterAuth() {
                                        return null;
                                    }
                                };
                                panel.enableButtonByRemote(statusMap);
                                AutoPrinterApp.getClientMain().setTopUI(panel);
                                bottomRealHeight = panel.getCurrentGuideBean().getHeight();
                            }
                        }
                    }.run();

                    return null;
                }

                @Override
                public void onSucceeded(Object object) {
                    final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
                    int maxHeight = screenSize.height - topRealHeight - bottomRealHeight;

                    final int finalHeight = maxHeight > screenSize.height ? screenSize.height : maxHeight;

                    new OpenGuidePaperTask(Constants.GUIDE_MAIN_FILE) {
                        @Override
                        public void onSucceed(Object object, HashMap<String, Integer> statusMap) {
                            if (object == null || object instanceof Exception) {
                            } else if (object instanceof GuideBean) {
                                GuideBean guideBean = (GuideBean) object;
                                GuidePanel panel = new GuidePanel(null, guideBean, maxWidth,
                                        finalHeight == 0 ? guideBean.getHeight() : finalHeight) {

                                    @Override
                                    public GuidePanel parentGuideWindow() {
                                        return null;
                                    }

                                    @Override
                                    public GuidePanel targetWindowAfterAuth() {
                                        return null;
                                    }
                                };
                                panel.enableButtonByRemote(statusMap);
                                AutoPrinterApp.getClientMain().setWorkUI(panel);
                            }
                        }

                    }.execute();

                }

            }.execute();

        }
    }.execute();

}