BoundedTableModel is used as a data model
* for {@link com.michaelbaranov.microba.marker.MarkerBar},
- * {@link com.michaelbaranov.microba.gradient.GradientBar},
- * {@link com.michaelbaranov.microba.gradienteditor.GradientEditor}
+ * {@link com.michaelbaranov.microba.gradient.GradientBar}
*
* @version 0.1 (rev. 13 Aug 2005)
* @author Michael Baranov
- * This implementation is mutable.
- *
- * @author Michael Baranov
- *
- */
-public class DefaultGradientEditorModel extends
- AbstractBoundedTableModelWithSelection implements MarkerMutationModel {
-
- public static final int POSITION_COLUMN = 0;
-
- public static final int COLOR_COLUMN = 1;
-
- protected List- * - * This is a component for displaying/modifying a gradient (palette). - * - *
- * Implementation details:
- * This implementation combines a {@link GradientBar} with two {@link MarkerBar}
- * components. The marker bars are used to provide editing capabilities to the
- * gradient bar. Note, that this component doesn't provide direct
- * color-selecting capabilitied but relies on other external components such as
- * {@link JColorChooser}.
- *
- * @author Michael Baranov
- *
- */
-public class GradientEditor extends GradientBar {
-
- /**
- * The name of a "colorSelectionModel" property.
- */
- public static final String PROPERTY_COLOR_SELECTION_MODEL = "colorSelectionModel";
-
- /**
- * The name of a "alphaSelectionModel" property.
- */
- public static final String PROPERTY_ALPHA_SELECTION_MODEL = "alphaSelectionModel";
-
- /**
- * The name of a "colorMutationModel" property.
- */
- public static final String PROPERTY_COLOR_MUTATION_MODEL = "colorMutationModel";
-
- /**
- * The name of a "alphaMutationModel" property.
- */
- public static final String PROPERTY_ALPHA_MUTATION_MODEL = "alphaMutationModel";
-
- private static final String uiClassID = "microba.GradientEditorUI";
-
- private ListSelectionModel colorSelectionModel = null;
-
- private ListSelectionModel alphaSelectionModel = null;
-
- private MarkerMutationModel colorMutationModel = null;
-
- private MarkerMutationModel alphaMutationModel = null;
-
- /**
- * Constructor.
- */
- public GradientEditor() {
- super();
- DefaultGradientEditorModel defaultGradientEditorModel = new DefaultGradientEditorModel();
- dataModel = defaultGradientEditorModel;
- colorSelectionModel = defaultGradientEditorModel;
- colorMutationModel = defaultGradientEditorModel;
- setFocusable(true);
- updateUI();
- }
-
- @Override
- public String getUIClassID() {
- return uiClassID;
- }
-
- /**
- * Regturns the current color mutation model.
- *
- * @return current color mutation model
- * @see #setColorMutationModel(MarkerMutationModel)
- * @see MarkerMutationModel
- */
- public MarkerMutationModel getColorMutationModel() {
- return colorMutationModel;
- }
-
- /**
- * Replaces current color mutation model with given one.
- *
- * @param mutationModel
- * new mutation model. May be null.
- * @see #getColorMutationModel()
- * @see MarkerMutationModel
- */
- public void setColorMutationModel(MarkerMutationModel mutationModel) {
- MarkerMutationModel oldMutationModel = this.colorMutationModel;
- this.colorMutationModel = mutationModel;
- firePropertyChange(PROPERTY_COLOR_MUTATION_MODEL, oldMutationModel, mutationModel);
- }
-
- /**
- * Returns current color selection model.
- *
- * @return current color selection model.
- * @see #setColorSelectionModel(ListSelectionModel)
- */
- public ListSelectionModel getColorSelectionModel() {
- return colorSelectionModel;
- }
-
- /**
- * Replaces current color selection model with given one. This
- * implementation uses
- * {@link ListSelectionModel#getLeadSelectionIndex()} to
- * determine selected marker.
- *
- * @param selectionModel
- * new selection model. May be null.
- *
- * @see #getColorSelectionModel()
- */
- public void setColorSelectionModel(ListSelectionModel selectionModel) {
- ListSelectionModel oldSelectionModel = this.colorSelectionModel;
- this.colorSelectionModel = selectionModel;
- firePropertyChange(PROPERTY_COLOR_SELECTION_MODEL, oldSelectionModel,
- selectionModel);
- }
-
- /**
- * Returns current alpha selection model.
- *
- * @return current alpha selection model.
- * @see #setAlphaSelectionModel(ListSelectionModel)
- */
- public ListSelectionModel getAlphaSelectionModel() {
- return alphaSelectionModel;
- }
-
- /**
- * Replaces current alpha selection model with given one. This
- * implementation uses
- * {@link ListSelectionModel#getLeadSelectionIndex()} to
- * determine selected marker.
- *
- * @param selectionModel
- * new selection model. May be null.
- *
- * @see #getAlphaSelectionModel()
- */
- public void setAlphaSelectionModel(ListSelectionModel selectionModel) {
- this.alphaSelectionModel = selectionModel;
- }
-
- /**
- * Regturns the current alpha mutation model.
- *
- * @return current alpha mutation model
- * @see #setAlphaMutationModel(MarkerMutationModel)
- * @see MarkerMutationModel
- */
- public MarkerMutationModel getAlphaMutationModel() {
- return alphaMutationModel;
- }
-
- /**
- * Replaces current alpha mutation model with given one.
- *
- * @param mutationModel
- * new mutation model. May be null.
- * @see #getAlphaMutationModel()
- * @see MarkerMutationModel
- */
- public void setAlphaMutationModel(MarkerMutationModel mutationModel) {
- this.alphaMutationModel = mutationModel;
- }
-
-}
diff --git a/libraries/microba/src/com/michaelbaranov/microba/gradienteditor/ui/GradientEditorLayout.java b/libraries/microba/src/com/michaelbaranov/microba/gradienteditor/ui/GradientEditorLayout.java
deleted file mode 100644
index 4ff7592e0e8b..000000000000
--- a/libraries/microba/src/com/michaelbaranov/microba/gradienteditor/ui/GradientEditorLayout.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package com.michaelbaranov.microba.gradienteditor.ui;
-
-import com.michaelbaranov.microba.gradient.GradientBar;
-import com.michaelbaranov.microba.gradienteditor.GradientEditor;
-import com.michaelbaranov.microba.marker.MarkerBar;
-
-import javax.swing.*;
-import java.awt.*;
-
-public class GradientEditorLayout implements LayoutManager {
-
- private final MarkerBar bar;
-
- private final GradientBar gradient;
-
- public GradientEditorLayout(MarkerBar bar, GradientBar gradient) {
- this.bar = bar;
- this.gradient = gradient;
- }
-
- @Override
- public void addLayoutComponent(String name, Component comp) {
- }
-
- @Override
- public void removeLayoutComponent(Component comp) {
- }
-
- @Override
- public Dimension preferredLayoutSize(Container parent) {
- return parent.getPreferredSize();
- }
-
- @Override
- public Dimension minimumLayoutSize(Container parent) {
- return parent.getMinimumSize();
- }
-
- @Override
- public void layoutContainer(Container parent) {
- GradientEditor e = (GradientEditor) parent;
- Insets i = parent.getInsets();
- int gap = bar.getMarkerSideGap();
- if (e.getOrientation() == SwingConstants.HORIZONTAL) {
- bar.setBounds(i.left, i.top, parent.getWidth() - i.left - i.right,
- bar.getPreferredSize().height);
- gradient.setBounds(i.left + gap, bar.getBounds().y
- + bar.getBounds().height, parent.getWidth() - i.left
- - i.right - gap - gap, parent.getHeight() - i.top
- - i.bottom - bar.getHeight());
- } else {
- gradient.setBounds(i.left, i.top+gap,
- gradient.getPreferredSize().width,parent.getHeight() - i.top - i.bottom-gap-gap);
- bar.setBounds(gradient.getBounds().x+gradient.getBounds().width ,i.top,
- bar.getPreferredSize().width,gradient.getBounds().height+gap+gap);
-
- }
- }
-
-}
diff --git a/libraries/microba/src/com/michaelbaranov/microba/gradienteditor/ui/GradientEditorUI.java b/libraries/microba/src/com/michaelbaranov/microba/gradienteditor/ui/GradientEditorUI.java
deleted file mode 100644
index 44ed4f374c1f..000000000000
--- a/libraries/microba/src/com/michaelbaranov/microba/gradienteditor/ui/GradientEditorUI.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.michaelbaranov.microba.gradienteditor.ui;
-
-import javax.swing.plaf.ComponentUI;
-
-public class GradientEditorUI extends ComponentUI{
-
-}
diff --git a/libraries/microba/src/com/michaelbaranov/microba/gradienteditor/ui/basic/BasicGradientEditorUI.java b/libraries/microba/src/com/michaelbaranov/microba/gradienteditor/ui/basic/BasicGradientEditorUI.java
deleted file mode 100644
index 6853aad838de..000000000000
--- a/libraries/microba/src/com/michaelbaranov/microba/gradienteditor/ui/basic/BasicGradientEditorUI.java
+++ /dev/null
@@ -1,172 +0,0 @@
-package com.michaelbaranov.microba.gradienteditor.ui.basic;
-
-import java.awt.Dimension;
-import java.awt.FlowLayout;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-
-import javax.swing.JComponent;
-import javax.swing.ListSelectionModel;
-import javax.swing.SwingConstants;
-import javax.swing.plaf.ComponentUI;
-
-import com.michaelbaranov.microba.common.BoundedTableModel;
-import com.michaelbaranov.microba.gradient.GradientBar;
-import com.michaelbaranov.microba.gradienteditor.GradientEditor;
-import com.michaelbaranov.microba.gradienteditor.ui.GradientEditorLayout;
-import com.michaelbaranov.microba.gradienteditor.ui.GradientEditorUI;
-import com.michaelbaranov.microba.marker.MarkerBar;
-import com.michaelbaranov.microba.marker.MarkerMutationModel;
-
-public class BasicGradientEditorUI extends GradientEditorUI {
-
- protected GradientBar gradientBar;
-
- protected MarkerBar colorBar;
-
- protected MarkerBar alphaBar;
-
- private GradientEditor gradient;
-
- private GradientEditorListener editorListener;
-
- public static ComponentUI createUI(JComponent c) {
- return new BasicGradientEditorUI();
- }
-
- public void installUI(JComponent component) {
- gradient = (GradientEditor) component;
- editorListener = new GradientEditorListener();
- createAndConfigureSubcomponents();
- installSubcomponents();
- installListeners();
- gradient.revalidate();
- }
-
- public void uninstallUI(JComponent component) {
- // JGradient gradient = (JGradient) component;
- uninstallSubcomponents();
- uninstallListeners();
- }
-
- protected void installSubcomponents() {
- gradient.setLayout(new GradientEditorLayout(colorBar, gradientBar));
- gradient.add(colorBar);
- gradient.add(gradientBar);
- }
-
- protected void uninstallSubcomponents() {
- gradient.setLayout(new FlowLayout());
- gradient.remove(colorBar);
- gradient.remove(gradientBar);
- }
-
- private void installListeners() {
- gradient.addPropertyChangeListener(editorListener);
- }
-
- private void uninstallListeners() {
- gradient.removePropertyChangeListener(editorListener);
- }
-
- private void createAndConfigureSubcomponents() {
- gradientBar = new GradientBar(gradient.getDataModel());
- gradientBar.setOrientation(gradient.getOrientation());
- gradientBar.setColorPositionColumn(gradient.getColorPositionColumn());
- gradientBar.setColorColumn(gradient.getColorColumn());
-
- colorBar = new MarkerBar(gradient.getDataModel(), gradient
- .getColorSelectionModel());
- colorBar.setOrientation(gradient.getOrientation());
- colorBar.setMutationModel(gradient.getColorMutationModel());
- colorBar.setPositionColumn(gradient.getColorPositionColumn());
- colorBar.setColorColumn(gradient.getColorColumn());
-
- alphaBar = new MarkerBar(gradient.getDataModel(), gradient
- .getColorSelectionModel());
- alphaBar.setOrientation(gradient.getOrientation());
- alphaBar.setMutationModel(gradient.getColorMutationModel());
- alphaBar.setPositionColumn(gradient.getColorPositionColumn());
- alphaBar.setColorColumn(gradient.getColorColumn());
- }
-
- class GradientEditorListener implements PropertyChangeListener {
-
- public void propertyChange(PropertyChangeEvent evt) {
- if (GradientEditor.PROPERTY_DATA_MODEL
- .equals(evt.getPropertyName())) {
- gradientBar.setDataModel((BoundedTableModel) evt.getNewValue());
- colorBar.setDataModel((BoundedTableModel) evt.getNewValue());
- }
- if (GradientEditor.PROPERTY_COLOR_SELECTION_MODEL.equals(evt
- .getPropertyName())) {
- colorBar.setSelectionModel((ListSelectionModel) evt
- .getNewValue());
- }
- if (GradientEditor.PROPERTY_COLOR_MUTATION_MODEL.equals(evt
- .getPropertyName())) {
- colorBar.setMutationModel((MarkerMutationModel) evt
- .getNewValue());
- }
- if (GradientEditor.PROPERTY_COLOR_POSITION_COLUMN.equals(evt
- .getPropertyName())) {
- colorBar.setPositionColumn(((Integer) evt.getNewValue())
- .intValue());
- gradientBar
- .setColorPositionColumn(((Integer) evt.getNewValue())
- .intValue());
- }
- if (GradientEditor.PROPERTY_COLOR_COLUMN.equals(evt
- .getPropertyName())) {
- gradientBar.setColorColumn(((Integer) evt.getNewValue())
- .intValue());
- colorBar.setColorColumn(((Integer) evt.getNewValue())
- .intValue());
-
- }
- if (GradientEditor.PROPERTY_ORIENTATION.equals(evt
- .getPropertyName())) {
- colorBar.setOrientation(((Integer) evt.getNewValue())
- .intValue());
- gradientBar.setOrientation(((Integer) evt.getNewValue())
- .intValue());
- }
- if ("enabled".equals(evt.getPropertyName())) {
- colorBar.setEnabled(((Boolean) evt.getNewValue())
- .booleanValue());
- gradientBar.setEnabled(((Boolean) evt.getNewValue())
- .booleanValue());
- }
-
- }
-
- }
-
- public Dimension getMinimumSize(JComponent c) {
- GradientBar gradient = (GradientBar) c;
-
- Dimension minimumSize = gradientBar.getMinimumSize();
- Dimension minimumSize2 = colorBar.getMinimumSize();
- if (gradient.getOrientation() == SwingConstants.HORIZONTAL)
- return new Dimension(Math
- .max(minimumSize.width, minimumSize2.width),
- minimumSize.height + minimumSize2.height);
- else
- return new Dimension(minimumSize.width + minimumSize2.width, Math
- .max(minimumSize.height, minimumSize2.height));
-
- }
-
- public Dimension getPreferredSize(JComponent c) {
- Dimension preferredSize = gradientBar.getPreferredSize();
- Dimension preferredSize2 = colorBar.getPreferredSize();
- if (gradient.getOrientation() == SwingConstants.HORIZONTAL)
- return new Dimension(Math.max(preferredSize.width,
- preferredSize2.width), preferredSize.height
- + preferredSize2.height);
- else
- return new Dimension(preferredSize.width + preferredSize2.width,
- Math.max(preferredSize.height, preferredSize2.height));
- }
-
-}