Search in sources :

Example 81 with FontMetrics

use of java.awt.FontMetrics in project vcell by virtualcell.

the class GraphContainerLayoutVCellClassical method getPreferedSizeStructureMappingFeatureShape.

public Dimension getPreferedSizeStructureMappingFeatureShape(StructureMappingStructureShape shape, Graphics2D g) throws GraphModel.NotReadyException {
    FontMetrics fm = g.getFontMetrics();
    shape.getLabelSize().height = fm.getMaxAscent() + fm.getMaxDescent();
    shape.getLabelSize().width = fm.stringWidth(shape.getLabel());
    if (shape.countChildren() > 0) {
        int totalHeight = shape.getLabelSize().height;
        int maxWidth = shape.getLabelSize().width;
        for (Shape child : shape.getChildren()) {
            Dimension childDim = getPreferedSize(child, g);
            totalHeight += childDim.height + StructureShape.defaultSpacingY;
            maxWidth = Math.max(maxWidth, childDim.width);
        }
        shape.getSpaceManager().setSizePreferred((maxWidth + StructureShape.defaultSpacingX * 2), (totalHeight + StructureShape.defaultSpacingY));
    } else {
        shape.getSpaceManager().setSizePreferred((shape.getLabelSize().width + StructureShape.defaultSpacingX * 2), (shape.getLabelSize().height + StructureShape.defaultSpacingY * 2));
    }
    return shape.getSpaceManager().getSizePreferred();
}
Also used : SubVolumeContainerShape(cbit.vcell.graph.SubVolumeContainerShape) SpeciesContextShape(cbit.vcell.graph.SpeciesContextShape) MembraneShape(cbit.vcell.graph.MembraneShape) ReactionStepShape(cbit.vcell.graph.ReactionStepShape) GeometryContextStructureShape(cbit.vcell.graph.GeometryContextStructureShape) FeatureShape(cbit.vcell.graph.FeatureShape) StructureMappingStructureShape(cbit.vcell.graph.StructureMappingStructureShape) ContainerContainerShape(cbit.vcell.graph.ContainerContainerShape) ReactionContainerShape(cbit.vcell.graph.ReactionContainerShape) GeometryContextContainerShape(cbit.vcell.graph.GeometryContextContainerShape) GeometryContextGeometryShape(cbit.vcell.graph.GeometryContextGeometryShape) StructureShape(cbit.vcell.graph.StructureShape) GeometryClassLegendShape(cbit.vcell.graph.GeometryClassLegendShape) BioPaxShape(cbit.vcell.client.desktop.biomodel.pathway.shapes.BioPaxShape) FontMetrics(java.awt.FontMetrics) Dimension(java.awt.Dimension) Point(java.awt.Point)

Example 82 with FontMetrics

use of java.awt.FontMetrics in project vcell by virtualcell.

the class FluxReactionShape method getPreferedSizeSelf.

@Override
public Dimension getPreferedSizeSelf(Graphics2D g) {
    getSpaceManager().setSizePreferred(25, 25);
    if (getLabel() != null && getLabel().length() > 0) {
        FontMetrics fontMetrics = g.getFontMetrics();
        setLabelSize(fontMetrics.stringWidth(getLabel()), fontMetrics.getMaxAscent() + fontMetrics.getMaxDescent());
    }
    return getSpaceManager().getSizePreferred();
}
Also used : FontMetrics(java.awt.FontMetrics)

Example 83 with FontMetrics

use of java.awt.FontMetrics in project vcell by virtualcell.

the class MolecularComponentLargeShape method getStateStringWidth.

private static int getStateStringWidth(String s, Graphics gc, LargeShapeCanvas shapePanel) {
    Font font = deriveStateFont(gc, shapePanel);
    FontMetrics fm = gc.getFontMetrics(font);
    return fm.stringWidth(s);
}
Also used : FontMetrics(java.awt.FontMetrics) Font(java.awt.Font)

Example 84 with FontMetrics

use of java.awt.FontMetrics in project vcell by virtualcell.

the class MolecularComponentLargeShape method computeStateHeight.

public static int computeStateHeight(Graphics gc, LargeShapeCanvas shapePanel) {
    Font font = deriveStateFont(gc, shapePanel);
    FontMetrics fm = gc.getFontMetrics(font);
    if (shapePanel.getZoomFactor() < LargeShapeCanvas.SmallestZoomFactorWithText) {
        // when we zoom to very small shapes we stop showing text, hence no need to reserve pixels
        return fm.getHeight() + 1;
    } else {
        // we allow 2 pixels above and below the state text
        return fm.getHeight() + 4;
    }
}
Also used : FontMetrics(java.awt.FontMetrics) Font(java.awt.Font)

Example 85 with FontMetrics

use of java.awt.FontMetrics in project vcell by virtualcell.

the class MolecularComponentLargeShape method getStringHeight.

private int getStringHeight(Font font) {
    Graphics gc = shapePanel.getGraphics();
    FontMetrics fm = gc.getFontMetrics(font);
    int stringHeight = fm.getHeight();
    return stringHeight;
}
Also used : Graphics(java.awt.Graphics) FontMetrics(java.awt.FontMetrics) Paint(java.awt.Paint)

Aggregations

FontMetrics (java.awt.FontMetrics)179 Font (java.awt.Font)61 Graphics2D (java.awt.Graphics2D)35 Point (java.awt.Point)34 Dimension (java.awt.Dimension)29 Color (java.awt.Color)23 Rectangle (java.awt.Rectangle)21 Rectangle2D (java.awt.geom.Rectangle2D)21 Insets (java.awt.Insets)20 Graphics (java.awt.Graphics)16 FilteredTreeModel (gov.sandia.n2a.ui.eq.FilteredTreeModel)14 GradientPaint (java.awt.GradientPaint)14 MPart (gov.sandia.n2a.eqset.MPart)13 NodeBase (gov.sandia.n2a.ui.eq.tree.NodeBase)12 Paint (java.awt.Paint)10 JTree (javax.swing.JTree)10 BasicStroke (java.awt.BasicStroke)9 BufferedImage (java.awt.image.BufferedImage)9 PanelModel (gov.sandia.n2a.ui.eq.PanelModel)8 JLabel (javax.swing.JLabel)8