Search in sources :

Example 1 with ColorAttribute

use of doc.attributes.ColorAttribute in project OpenNotebook by jaltekruse.

the class ColorAdjustmentPanel method addPanelContent.

@Override
public void addPanelContent() {
    setLayout(new GridBagLayout());
    if (mAtt.getName().equals(MathObject.FILL_COLOR)) {
        checkbox = new JCheckBox("fill");
        if (mAtt.getValue() != null)
            checkbox.setSelected(true);
        else
            checkbox.setSelected(false);
        checkbox.addItemListener(new ItemListener() {

            @Override
            public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    if (justChangedColor) {
                        justChangedColor = false;
                        return;
                    }
                    if (mAtt.getValue() == null) {
                        mAtt.setValue(Color.WHITE);
                    }
                    colorLabel.setBackground(mAtt.getValue());
                    ColorAdjustmentPanel.this.repaint();
                    notebookPanel.getCurrentDocViewer().addUndoState();
                    notebookPanel.getCurrentDocViewer().repaintDoc();
                    notebookPanel.getCurrentDocViewer().updateObjectToolFrame();
                } else {
                    mAtt.setValue(null);
                    colorLabel.setBackground(mAtt.getValue());
                    ColorAdjustmentPanel.this.repaint();
                    notebookPanel.getCurrentDocViewer().addUndoState();
                    notebookPanel.getCurrentDocViewer().repaintDoc();
                    notebookPanel.getCurrentDocViewer().updateObjectToolFrame();
                }
            }
        });
    }
    colorLabel = new JLabel("    ");
    colorLabel.setBorder(new LineBorder(Color.BLACK));
    colorLabel.setOpaque(true);
    colorLabel.setBackground(mAtt.getValue());
    colorLabel.addMouseListener(new MouseListener() {

        public void mouseClicked(MouseEvent arg0) {
        }

        public void mouseEntered(MouseEvent arg0) {
        }

        public void mouseExited(MouseEvent arg0) {
        }

        public void mousePressed(MouseEvent arg0) {
            Color c = JColorChooser.showDialog(ColorAdjustmentPanel.this, "Choose color", ((ColorAttribute) mAtt).getValue());
            ((ColorAttribute) mAtt).setValue(c);
            colorLabel.setBackground(mAtt.getValue());
            if (checkbox != null) {
                if (((ColorAttribute) mAtt).getValue() != null) {
                    justChangedColor = true;
                    checkbox.setSelected(true);
                } else {
                    checkbox.setSelected(false);
                }
            }
            notebookPanel.getCurrentDocViewer().addUndoState();
            notebookPanel.getCurrentDocViewer().repaintDoc();
        }

        public void mouseReleased(MouseEvent arg0) {
        }
    });
    GridBagConstraints con = new GridBagConstraints();
    con.fill = GridBagConstraints.HORIZONTAL;
    con.weightx = 1;
    con.gridx = 0;
    con.gridy = 0;
    con.insets = new Insets(0, 0, 0, 3);
    if (mAtt.getName().equals(MathObject.FILL_COLOR)) {
        add(checkbox, con);
    } else {
        add(new JLabel(mAtt.getName()), con);
    }
    con.gridy = 0;
    con.gridx = 1;
    con.gridheight = 1;
    add(colorLabel, con);
// con.gridx = 2;
// add(setColor, con);
}
Also used : ItemEvent(java.awt.event.ItemEvent) GridBagConstraints(java.awt.GridBagConstraints) MouseEvent(java.awt.event.MouseEvent) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) LineBorder(javax.swing.border.LineBorder) Color(java.awt.Color) JLabel(javax.swing.JLabel) JCheckBox(javax.swing.JCheckBox) MouseListener(java.awt.event.MouseListener) ItemListener(java.awt.event.ItemListener) ColorAttribute(doc.attributes.ColorAttribute)

Example 2 with ColorAttribute

use of doc.attributes.ColorAttribute in project OpenNotebook by jaltekruse.

the class PolygonObject method addPolygonAttributes.

private void addPolygonAttributes() {
    addAttribute(new IntegerAttribute(LINE_THICKNESS, 1, 1, 20));
    addAttribute(new ColorAttribute(FILL_COLOR));
    addAttribute(new BooleanAttribute(HORIZONTALLY_FLIPPED, false, false));
    getAttributeWithName(HORIZONTALLY_FLIPPED).setValue(false);
    addAttribute(new BooleanAttribute(VERTICALLY_FLIPPED, false, false));
    getAttributeWithName(VERTICALLY_FLIPPED).setValue(false);
}
Also used : BooleanAttribute(doc.attributes.BooleanAttribute) ColorAttribute(doc.attributes.ColorAttribute) IntegerAttribute(doc.attributes.IntegerAttribute)

Example 3 with ColorAttribute

use of doc.attributes.ColorAttribute in project OpenNotebook by jaltekruse.

the class ExpressionObject method addDefaultAttributes.

@Override
protected void addDefaultAttributes() {
    addAttribute(new StringAttribute(EXPRESSION));
    addList(new ListAttribute<>(CORRECT_ANSWERS, new StringAttribute(""), 20, true, false));
    addList(new ListAttribute<>(STEPS, new StringAttribute("val"), false));
    addAttribute(new IntegerAttribute(FONT_SIZE, 1, 50));
    addAttribute(new ColorAttribute(FILL_COLOR));
    addAttribute(new BooleanAttribute(ALWAYS_SHOW_STEPS, true, true, false));
    getAttributeWithName(EXPRESSION).setValue("");
    getAttributeWithName(FONT_SIZE).setValue(12);
    getAttributeWithName(FILL_COLOR).setValue(null);
}
Also used : BooleanAttribute(doc.attributes.BooleanAttribute) StringAttribute(doc.attributes.StringAttribute) ColorAttribute(doc.attributes.ColorAttribute) IntegerAttribute(doc.attributes.IntegerAttribute)

Example 4 with ColorAttribute

use of doc.attributes.ColorAttribute in project OpenNotebook by jaltekruse.

the class ConeObject method addDefaultAttributes.

@Override
public void addDefaultAttributes() {
    addAttribute(new IntegerAttribute(LINE_THICKNESS, 1, 1, 20));
    addAttribute(new ColorAttribute(FILL_COLOR, null));
    addAttribute(new BooleanAttribute(VERTICALLY_FLIPPED, false, false));
}
Also used : BooleanAttribute(doc.attributes.BooleanAttribute) ColorAttribute(doc.attributes.ColorAttribute) IntegerAttribute(doc.attributes.IntegerAttribute)

Example 5 with ColorAttribute

use of doc.attributes.ColorAttribute in project OpenNotebook by jaltekruse.

the class LineObject method addDefaultAttributes.

public void addDefaultAttributes() {
    // addAttribute(new EnumeratedAttribute(ORIENTATION, LEFT_TOP, false, false, orientations));
    addAttribute(new BooleanAttribute(HORIZONTALLY_FLIPPED, false, false, false));
    addAttribute(new BooleanAttribute(VERTICALLY_FLIPPED, false, false, false));
    addAttribute(new IntegerAttribute(LINE_THICKNESS, 1, 1, 20, true, false));
    addAttribute(new ColorAttribute(LINE_COLOR, Color.BLACK, true, false));
    addAction(FLIP_HORIZONTALLY);
    addAction(FLIP_VERTICALLY);
}
Also used : BooleanAttribute(doc.attributes.BooleanAttribute) ColorAttribute(doc.attributes.ColorAttribute) IntegerAttribute(doc.attributes.IntegerAttribute)

Aggregations

ColorAttribute (doc.attributes.ColorAttribute)9 IntegerAttribute (doc.attributes.IntegerAttribute)8 BooleanAttribute (doc.attributes.BooleanAttribute)7 StringAttribute (doc.attributes.StringAttribute)2 AttributeException (doc.attributes.AttributeException)1 DoubleAttribute (doc.attributes.DoubleAttribute)1 GridPointAttribute (doc.attributes.GridPointAttribute)1 SelectionAttribute (doc.attributes.SelectionAttribute)1 Selection (doc_gui.graph.Selection)1 Color (java.awt.Color)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 ItemEvent (java.awt.event.ItemEvent)1 ItemListener (java.awt.event.ItemListener)1 MouseEvent (java.awt.event.MouseEvent)1 MouseListener (java.awt.event.MouseListener)1 JCheckBox (javax.swing.JCheckBox)1 JLabel (javax.swing.JLabel)1 LineBorder (javax.swing.border.LineBorder)1