Search in sources :

Example 6 with JToolBarToggleButton

use of org.vcell.util.gui.JToolBarToggleButton in project vcell by virtualcell.

the class ReactionCartoonEditorPanel method getSizeByWeightButton.

private JToolBarToggleButton getSizeByWeightButton() {
    if (sizeByWeightButton == null) {
        try {
            JToolBarToggleButton button = new JToolBarToggleButton();
            SpeciesSizeShapeIcon.setSpeciesSizeShapeMod(button, SpeciesSizeShapeIcon.Kind.weight);
            button.setActionCommand(Mode.SIZEBYWEIGHT.getActionCommand());
            sizeByWeightButton = button;
        } catch (Throwable throwable) {
            handleException(throwable);
        }
    }
    return sizeByWeightButton;
}
Also used : JToolBarToggleButton(org.vcell.util.gui.JToolBarToggleButton)

Example 7 with JToolBarToggleButton

use of org.vcell.util.gui.JToolBarToggleButton in project vcell by virtualcell.

the class ReactionCartoonEditorPanel method getEqualSizeButton.

private JToolBarToggleButton getEqualSizeButton() {
    if (equalSizeButton == null) {
        try {
            JToolBarToggleButton button = new JToolBarToggleButton();
            SpeciesSizeShapeIcon.setSpeciesSizeShapeMod(button, SpeciesSizeShapeIcon.Kind.equal);
            button.setActionCommand(Mode.EQUALSIZE.getActionCommand());
            equalSizeButton = button;
        } catch (Throwable throwable) {
            handleException(throwable);
        }
    }
    return equalSizeButton;
}
Also used : JToolBarToggleButton(org.vcell.util.gui.JToolBarToggleButton)

Example 8 with JToolBarToggleButton

use of org.vcell.util.gui.JToolBarToggleButton in project vcell by virtualcell.

the class ReactionToolShapeIcon method paintIcon.

@Override
public void paintIcon(Component comp, Graphics g, int x, int y) {
    if (comp == null) {
        return;
    }
    if (!(comp instanceof JToolBarToggleButton)) {
        return;
    }
    JToolBarToggleButton button = (JToolBarToggleButton) comp;
    Graphics2D g2 = (Graphics2D) g;
    Color colorOld = g2.getColor();
    Paint paintOld = g2.getPaint();
    Stroke strokeOld = g2.getStroke();
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setStroke(new BasicStroke(2f));
    Color c1, c2, c3, c4;
    // for the arrowhead
    float x1, x2, y1, y2;
    int xx = x - 16;
    int yy = y - 15;
    // we'll paint a small arc from the upper left part of a very large circle
    int w = diameter * 8;
    int h = diameter * 8;
    // the start and end coordinates of the membrane (for the flux button)
    float m1 = 9f;
    float m2 = 14f;
    if (state == State.normal) {
        // paint yellow arc
        c1 = Color.yellow.darker();
        c2 = Color.yellow;
        c3 = Color.black;
        c4 = Color.yellow.darker();
        x1 = 0;
        x2 = 0;
        y1 = 0;
        y2 = 0;
    } else {
        c1 = Color.yellow.darker();
        c2 = Color.yellow.brighter();
        c3 = Color.black;
        c4 = Color.yellow.darker().darker();
        xx += 1;
        yy += 1;
        x1 = 1;
        x2 = 1;
        y1 = 1;
        y2 = 1;
        m1 += 1.0f;
        m2 += 1.0f;
    }
    Arc2D arc;
    if (mode == Mode.catalyst) {
        arc = new Arc2D.Double(xx, yy, w, h, 125, 18, Arc2D.OPEN);
    } else {
        arc = new Arc2D.Double(xx, yy, w, h, // starting angle
        126, // angular extent
        18, Arc2D.OPEN);
    }
    int a = 0;
    int b = -10;
    int c = 12;
    // the wide yellow halo
    g2.setStroke(new BasicStroke(4.0f));
    GradientPaint gp = new GradientPaint(a, b, c1, a + c, b - c, c2, true);
    g2.setPaint(gp);
    g2.draw(arc);
    if (mode == Mode.flux) {
        // the "membrane" line, only for flux reactions
        g2.setStroke(new BasicStroke(5.0f));
        g2.setPaint(Color.orange.darker());
        Line2D line = new Line2D.Float(m1, m1, m2, m2);
        g2.draw(line);
    }
    if (mode == Mode.catalyst) {
        // dashed black line for catalyst
        float[] dash = { 6.2f, 3.6f };
        Stroke dashed = new BasicStroke(1.6f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, dash, 0);
        g2.setStroke(dashed);
        g2.setPaint(Color.black);
        // gp = new GradientPaint(a, b, c3, a+c, b-c, c4, true);
        // g2.setPaint(gp);
        g2.draw(arc);
    } else {
        // the continuous black line for plain and flux reactions
        g2.setStroke(new BasicStroke(2f));
        gp = new GradientPaint(a, b, c3, a + c, b - c, c4, true);
        g2.setPaint(gp);
        g2.draw(arc);
    }
    // TODO: draw arrow (maybe)
    // g2.setStroke(new BasicStroke(1.4f,				// Line width
    // BasicStroke.CAP_ROUND,					// End-cap style
    // BasicStroke.JOIN_ROUND));				// Vertex join style
    // Line2D l1 = new Line2D.Float(x1, y1, x2, y2);
    // Line2D l2 = new Line2D.Float(x1, y1, x2, y2);
    // g2.draw(l1);
    // g2.draw(l2);
    g2.setStroke(strokeOld);
    g2.setColor(colorOld);
    g2.setPaint(paintOld);
}
Also used : BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) Color(java.awt.Color) GradientPaint(java.awt.GradientPaint) Paint(java.awt.Paint) GradientPaint(java.awt.GradientPaint) Arc2D(java.awt.geom.Arc2D) Line2D(java.awt.geom.Line2D) JToolBarToggleButton(org.vcell.util.gui.JToolBarToggleButton) Paint(java.awt.Paint) GradientPaint(java.awt.GradientPaint) Graphics2D(java.awt.Graphics2D)

Example 9 with JToolBarToggleButton

use of org.vcell.util.gui.JToolBarToggleButton in project vcell by virtualcell.

the class GroupMoleculeToolShape method paintIcon.

@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
    if (c == null) {
        return;
    }
    if (!(c instanceof JToolBarToggleButton)) {
        return;
    }
    JToolBarToggleButton b = (JToolBarToggleButton) c;
    Graphics2D g2 = (Graphics2D) g;
    Color colorOld = g2.getColor();
    Paint paintOld = g2.getPaint();
    Stroke strokeOld = g2.getStroke();
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    Color c1;
    Color c2;
    Color c3;
    Color c4;
    // offset from upper left corner
    int init;
    switch(state) {
        case normal:
            init = 0;
            c1 = Color.red.darker();
            c2 = Color.darkGray;
            c3 = Color.gray;
            c4 = AbstractComponentShape.componentMediumPalePink;
            break;
        case selected:
            init = 1;
            c1 = Color.red.darker().darker();
            c2 = Color.darkGray;
            c3 = Color.gray;
            c4 = AbstractComponentShape.componentPalePink;
            break;
        case disabled:
        default:
            init = 0;
            c1 = Color.lightGray;
            c2 = Color.lightGray;
            c3 = Color.lightGray;
            c4 = AbstractComponentShape.componentMediumPalePink;
            break;
    }
    g2.setStroke(new BasicStroke(1.2f));
    g2.setPaint(c2);
    // the large square
    final int delta = 15;
    int xx = x + init + 1;
    int yy = y + init + 1;
    Rectangle2D rect = new Rectangle2D.Double(xx, yy, delta + 1, delta);
    g2.draw(rect);
    g2.setStroke(new BasicStroke(0.8f));
    final int delta2 = 7;
    // the lower small rectangle
    xx += 5;
    yy += 5;
    rect = new Rectangle2D.Double(xx, yy, delta2 + 1, delta2);
    g2.setPaint(c3);
    g2.draw(rect);
    // the upper small rectangle
    xx -= 2;
    yy -= 2;
    rect = new Rectangle2D.Double(xx, yy, delta2 + 1, delta2);
    g2.setPaint(c4);
    // overwrite some of the smaller rectangle
    g2.fill(rect);
    g2.setPaint(c3);
    g2.draw(rect);
    // ---------------------------------------------------------------------
    int m = 3;
    // upper left corner small red square
    g2.setStroke(new BasicStroke(1.0f));
    g2.setPaint(c1);
    xx = x + init;
    yy = y + init;
    rect = new Rectangle2D.Double(xx, yy, m, m);
    // g2.draw(rect);
    g2.fill(rect);
    xx = x + init + delta + 1;
    yy = y + init;
    rect = new Rectangle2D.Double(xx, yy, m, m);
    g2.fill(rect);
    xx = x + init;
    yy = y + init + delta;
    rect = new Rectangle2D.Double(xx, yy, m, m);
    g2.fill(rect);
    xx = x + init + delta + 1;
    yy = y + init + delta;
    rect = new Rectangle2D.Double(xx, yy, m, m);
    g2.fill(rect);
    g2.setStroke(strokeOld);
    g2.setColor(colorOld);
    g2.setPaint(paintOld);
}
Also used : BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) Color(java.awt.Color) Rectangle2D(java.awt.geom.Rectangle2D) Paint(java.awt.Paint) JToolBarToggleButton(org.vcell.util.gui.JToolBarToggleButton) Paint(java.awt.Paint) Graphics2D(java.awt.Graphics2D)

Example 10 with JToolBarToggleButton

use of org.vcell.util.gui.JToolBarToggleButton in project vcell by virtualcell.

the class ReactionCartoonEditorPanel method getStructureButton.

private JToolBarToggleButton getStructureButton() {
    if (structureButton == null) {
        try {
            JToolBarToggleButton button = new JToolBarToggleButton();
            StructureToolShapeIcon.setStructureToolMod(button);
            button.setActionCommand(Mode.STRUCTURE.getActionCommand());
            structureButton = button;
        // structureButton = createModeButton("StructureButton", "Structure Tool", Mode.STRUCTURE, loadIcon("/images/feature.gif"));
        } catch (Throwable throwable) {
            handleException(throwable);
        }
    }
    return structureButton;
}
Also used : JToolBarToggleButton(org.vcell.util.gui.JToolBarToggleButton)

Aggregations

JToolBarToggleButton (org.vcell.util.gui.JToolBarToggleButton)18 Color (java.awt.Color)5 Graphics2D (java.awt.Graphics2D)5 Paint (java.awt.Paint)5 Stroke (java.awt.Stroke)5 BasicStroke (java.awt.BasicStroke)4 Rectangle2D (java.awt.geom.Rectangle2D)3 GradientPaint (java.awt.GradientPaint)1 RadialGradientPaint (java.awt.RadialGradientPaint)1 Arc2D (java.awt.geom.Arc2D)1 Ellipse2D (java.awt.geom.Ellipse2D)1 Line2D (java.awt.geom.Line2D)1 Point2D (java.awt.geom.Point2D)1 ButtonModel (javax.swing.ButtonModel)1