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);
}
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);
}
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);
}
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));
}
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);
}
Aggregations