libmicroba-java-0.4.4.3.orig/0000775000175000017500000000000011057263622015141 5ustar gregoagregoalibmicroba-java-0.4.4.3.orig/change.log.txt0000644000175000017500000000753611050604100017677 0ustar gregoagregoav.0.4.4.3 * Added: CalendarPane.observeMonth(int, int); * Added: Slovak and Czech translation (thanks to Lubomir Grajciar) * Added: Hebrew translation (thanks to Moshe Elisha) * Added: Turkish translation (thanks to Emre Yazici) * Added: Hungarian translation (thanks to Zoltan Kuroli) v.0.4.4.2 * changed misspelled package name 'jgrpah' to 'jgraph' * fixed build script to correctly package resources (thanks to Velimir Gasparovic) v.0.4.4.1 * Change: changed project directory structure according to Maven guidelines. * Fixed: DatePicker popup did not close when clicked on already selecteed date. * CalendarPane.fireCommitEvent(boolean) made public * CalendarPane.fireActionEvent() made public v.0.4.4 * Added: DatePicker.dropdownFocusable property * Added: MicrobaComponent.colorOverrideMap property * Added: Microba.setColorOverrideMap method These two improvements allow to override colors on per-instance and per-L&F basis. Currenty CalendarPane and DatePicker support some color overriding. * Fixed: CalendarPane ignores enabled property v.0.4.3.4 (21 nov 2006) * Fixed: Microba works with NetBeans Matisse GUI editor. Thanks to Witold Szczerba for testing the fix. * Fixed: manifest now specifies javabeans * Refactored: common superclass extracted: MicrobaComponent v.0.4.3.3 * Fixed: DatePicker ignores locale passed in constructor v.0.4.3.2 * Fixed: DatePicker ignores showWeekNumber * Fixed: DatePicker may return wrong date via getDate() in some cases * Fixed: Portuguese translation corrected by Roger Araújo v.0.4.3.1 * Fixed: DatePicker displays no tooltip string * Fixed: DatePicker goes to infinite loop if keepTime is true, and date format has no time fields. Thanks to Wolfgang Fietzke for his excellent bug report! v0.4.3 * Added: Birdview component for JGraph library * Added: Swedish translation for DatePicker * Added: CalendarPane.stripDate ( and DatePicker.stripDate ) property (optional time stripping) * Added: DatePicker.keepTime property (improved time field handling) * Added: DatePicker.pickerStyle property (controls visual style of the picker itself) * Added: DatePicker.showButtonOnly() shortcut method * Added: static CalendarPane.stripDate(...) utility method * Fixed: DatePicker.setDateFormat(...) never fired a PropertyChangeEvent * Changed: picker-16.png ico for DatePicker changed v.0.4.2 (31 jul 2006) * Refactored: dateStyle property of DatePicker was dropped in favour of dateFormat property. However, old constructors preserved. * Fixed: OutOfMemory exception bug fixed. The bug prevented components to be garbage collected because references were held by Timer tasks. Regression: CalendarPane will update 'today' date only on creation. v.0.4.1 (18 jun 2006) * Added: ability to show number of weeks for DatePicker and CalendarPane. * Fixed: Applet refresh problem: see readme.txt, see Microba.init() * Fixed: Polish translation (thanks to Gregory Kaczmarczyk) v.0.4 (29 mar 2006) * Refactored: com.michaelbaranov.microba.common package introduced * Refactored: class HollidayPolicy renamed to HolidayPolicy * Refactored: properties named 'hollidayPolicy' renamed to 'holidayPolicy' in all classes * Refactored: renamed recources in com.michaelbaranov.microba.calendar.resource: 16.png -> picker-16.png l.png -> back-16.png ll.png -> back-fast-16.png r.png -> forward-16.png rr.png -> forward-fast-16.png * Added: MarkerBar, GradientBar, GradientEditor controls * Added: multiple translations for CalendarPane UI * Added: enabled/disabled state for DatePicker and CalendarPane * Fixed: DatePickerCellEditor not respected focus lost behavior of the DatePicker. Now it is possible to commit cell edit when cell edit stops (e.g. tab out). v.0.3 (15 dec 2005) * First public release libmicroba-java-0.4.4.3.orig/META-INF/0000755000175000017500000000000011050604324016266 5ustar gregoagregoalibmicroba-java-0.4.4.3.orig/META-INF/MANIFEST.MF0000644000175000017500000000014611050604322017717 0ustar gregoagregoaManifest-Version: 1.0 Ant-Version: Apache Ant 1.7.0 Created-By: 10.0-b22 (Sun Microsystems Inc.) libmicroba-java-0.4.4.3.orig/src/0000755000175000017500000000000010634142534015724 5ustar gregoagregoalibmicroba-java-0.4.4.3.orig/src/main/0000755000175000017500000000000010634142130016640 5ustar gregoagregoalibmicroba-java-0.4.4.3.orig/src/main/java/0000755000175000017500000000000010706253360017571 5ustar gregoagregoalibmicroba-java-0.4.4.3.orig/src/main/java/Snippet.java0000644000175000017500000000207111013067372022054 0ustar gregoagregoaimport java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.PropertyVetoException; import javax.swing.JButton; import javax.swing.JFrame; import com.michaelbaranov.microba.calendar.DatePicker; public class Snippet { public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setLayout(new FlowLayout()); final DatePicker picker = new DatePicker(); picker.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println(picker.getDate()); } }); JButton btn = new JButton("NULL"); btn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { picker.setDate(null); } catch (PropertyVetoException e1) { System.out.println("Could not set null date."); e1.printStackTrace(); } picker.setEnabled(false); } }); frame.add(picker); frame.add(btn); frame.setSize(640, 480); frame.setVisible(true); } } libmicroba-java-0.4.4.3.orig/src/main/java/com/0000755000175000017500000000000010634142130020337 5ustar gregoagregoalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/0000755000175000017500000000000010634142130023312 5ustar gregoagregoalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/0000755000175000017500000000000010724465710024742 5ustar gregoagregoalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/jgraph/0000755000175000017500000000000010724465710026215 5ustar gregoagregoalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/jgraph/birdview/0000755000175000017500000000000010724465710030030 5ustar gregoagregoalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/jgraph/birdview/Birdview.java0000644000175000017500000002263410724465712032457 0ustar gregoagregoapackage com.michaelbaranov.microba.jgraph.birdview; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Point; import java.awt.Rectangle; import java.awt.event.AdjustmentEvent; import java.awt.event.AdjustmentListener; import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.UIManager; import org.jgraph.JGraph; import org.jgraph.event.GraphModelEvent; import org.jgraph.event.GraphModelListener; import org.jgraph.graph.GraphLayoutCache; /** * A JFC/Swing component that displays a bird-eyes (thumbnail) view of a * {@link JGraph} in combination with {@link JScrollPane}. Also allows to pan * view with the mouse. * * * @author Michael Baranov * */ public class Birdview extends JPanel { /** * Color constant */ public static final Color PAN_RECT_COLOR = Color.black; /** * Color constant */ public static final Color BACKGROUND_COLOR = UIManager.getColor("Panel.background"); /** * a {@link JGraph} component used as main display */ private JGraph displayGraph; /** * a {@link JScrollPane} to track */ private JScrollPane peerScroller; /** * a {@link JGraph} to tracl */ private JGraph peerGraph; /** * a rect, subrect of the component area, that matches the tracked view */ private Rectangle2D paintRect; /** * a rect, a subrect of the component area, that matches the tracked * viewport */ private Rectangle2D panRect; /** * the scale applied to {@link #displayGraph} to fit into {@link #paintRect} */ private double scale = 1.0; /** * A listener */ private ScrollerListener scrollerListener = new ScrollerListener(); /** * A listener */ private SelfMouseListener selfMouseListener = new SelfMouseListener(); /** * A listener */ private GraphPropertyChangeListener graphPropertyChangeListener = new GraphPropertyChangeListener(); /** * Constructor. * * @param doc * document to track. May be null */ public Birdview() { displayGraph = new JGraph(); displayGraph.setEnabled(false); displayGraph.setAntiAliased(true); displayGraph.addMouseListener(selfMouseListener); displayGraph.addMouseMotionListener(selfMouseListener); this.setLayout(null); this.addComponentListener(new SelfResizeListener()); this.add(displayGraph); } /** * Makes this component track the provided graph and scroller. Set * parameters to null to unbind thie component. * * @param graph * the graph component. May be null * @param scroller * the croller, usually the one that holds the graph. May be * null */ public void setTrackingFor(JGraph graph, JScrollPane scroller) { if (this.peerGraph != null) { this.peerGraph.getModel().removeGraphModelListener(scrollerListener); this.peerGraph.removePropertyChangeListener(graphPropertyChangeListener); } this.peerGraph = graph; if (this.peerGraph != null) { this.peerGraph.getModel().addGraphModelListener(scrollerListener); this.peerGraph.addPropertyChangeListener(graphPropertyChangeListener); this.displayGraph.setGraphLayoutCache(peerGraph.getGraphLayoutCache()); } else { this.displayGraph.setGraphLayoutCache(new GraphLayoutCache()); } // if (this.peerScroller != null) { this.peerScroller.getHorizontalScrollBar().removeAdjustmentListener( scrollerListener); this.peerScroller.getVerticalScrollBar().removeAdjustmentListener( scrollerListener); } this.peerScroller = scroller; if (this.peerScroller != null) { this.peerScroller.getHorizontalScrollBar().addAdjustmentListener( scrollerListener); this.peerScroller.getVerticalScrollBar().addAdjustmentListener( scrollerListener); } update(); repaint(); } /** * Calculates {@link #paintRect}, {@link #panRect}, {@link #scale} based * on observations of peerScroller. * */ private void update() { if (peerScroller != null) { Dimension viewSize = peerScroller.getViewport().getViewSize(); double viewAspect = viewSize.getHeight() / viewSize.getWidth(); Dimension panelSize = this.getSize(); double panelAspect = panelSize.getHeight() / panelSize.getWidth(); if (panelAspect < viewAspect) { // panel is wider, height is primary double desiredPanelWidth = panelSize.getHeight() / viewAspect; double blankWidth = panelSize.getWidth() - desiredPanelWidth; double gap = blankWidth / 2; paintRect = new Rectangle2D.Double(gap, 0, desiredPanelWidth, panelSize.height); scale = panelSize.getHeight() / viewSize.getHeight(); scale *= peerGraph.getScale(); } else { // panel is heigher, width is primary double desiredPanelHeight = panelSize.getWidth() * viewAspect; double blankHeight = panelSize.getHeight() - desiredPanelHeight; double gap = blankHeight / 2; paintRect = new Rectangle2D.Double(0, gap, panelSize.getWidth(), desiredPanelHeight); scale = panelSize.getWidth() / viewSize.getWidth(); scale *= peerGraph.getScale(); } Rectangle viewRect = peerScroller.getViewport().getViewRect(); double shiftX = viewRect.getX() / viewSize.getWidth(); double shiftY = viewRect.getY() / viewSize.getHeight(); double sizeX = viewRect.getWidth() / viewSize.getWidth(); double sizeY = viewRect.getHeight() / viewSize.getHeight(); panRect = new Rectangle2D.Double(paintRect.getX() + paintRect.getWidth() * shiftX, paintRect.getY() + paintRect.getHeight() * shiftY, paintRect.getWidth() * sizeX, paintRect.getHeight() * sizeY); } else { panRect = null; paintRect = null; scale = 1; } } /** * Addjusts {@link #panRect} to be postitionsed with the centter at a given * point if possible. This methods ensures that {@link #panRect} fits * entirely in {@link #paintRect}. * * @param point * the desired panRect center */ private void panRectTo(Point point) { Dimension viewSize = peerScroller.getViewport().getViewSize(); Rectangle viewRect = peerScroller.getViewport().getViewRect(); double panHalfWidth = panRect.getWidth() / 2; double panHalfHeight = panRect.getHeight() / 2; Point2D panOrigin = new Point2D.Double(point.x - panHalfWidth, point.y - panHalfHeight); double xk = panOrigin.getX() / paintRect.getWidth(); double yk = panOrigin.getY() / paintRect.getHeight(); Point viewPos = new Point((int) (viewSize.getWidth() * xk), (int) (viewSize .getHeight() * yk)); // make sure we do not pan past the bounds: if (viewPos.x < 0) viewPos.x = 0; if (viewPos.y < 0) viewPos.y = 0; int wd = (viewPos.x + viewRect.width) - viewSize.width; int hd = (viewPos.y + viewRect.height) - viewSize.height; if (wd > 0) viewPos.x -= wd; if (hd > 0) viewPos.y -= hd; // pan it peerScroller.getViewport().setViewPosition(viewPos); update(); repaint(); } public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; // fill background g2.setColor(BACKGROUND_COLOR); g2.fillRect(0, 0, this.getWidth(), this.getHeight()); if (peerGraph != null) { // paint the graph display displayGraph.setBounds(paintRect.getBounds()); displayGraph.setScale(scale); displayGraph.setBackground(peerGraph.getBackground()); paintChildren(g); } if (panRect != null) { // draw pan rect g2.setColor(PAN_RECT_COLOR); g2.draw(panRect.getBounds()); } } /** * A listener to watch for scrollbar movement. * * @author Michael Baranov * */ private class ScrollerListener implements AdjustmentListener, GraphModelListener { public void adjustmentValueChanged(AdjustmentEvent e) { update(); repaint(); } public void graphChanged(GraphModelEvent e) { update(); repaint(); } } /** * A listener to watch for sizing of the component itself. * * @author Michael Baranov * */ private class SelfResizeListener implements ComponentListener { public void componentHidden(ComponentEvent e) { } public void componentMoved(ComponentEvent e) { } public void componentResized(ComponentEvent e) { update(); repaint(); } public void componentShown(ComponentEvent e) { update(); repaint(); } } /** * A listener to watch for mouse for the component itself. * * @author Michael Baranov * */ private class SelfMouseListener implements MouseListener, MouseMotionListener { public void mouseClicked(MouseEvent e) { } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { if (paintRect != null) panRectTo(e.getPoint()); } public void mouseDragged(MouseEvent e) { if (paintRect != null) panRectTo(e.getPoint()); } public void mouseMoved(MouseEvent e) { } } /** * A listener to watch for graph property change, most important "scale". * * @author Michael Baranov * */ private class GraphPropertyChangeListener implements PropertyChangeListener { public void propertyChange(PropertyChangeEvent evt) { if ("scale".equals(evt.getPropertyName())) { update(); repaint(); } } } } libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/common/0000755000175000017500000000000010634142130026216 5ustar gregoagregoalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/common/Policy.java0000644000175000017500000000071110412660742030327 0ustar gregoagregoapackage com.michaelbaranov.microba.common; public interface Policy { /** * Adds a {@link PolicyListener}. * * @param listener * a {@link PolicyListener} to add */ public void addVetoPolicyListener(PolicyListener listener); /** * Removes a {@link PolicyListener}. * * @param listener * a {@link PolicyListener} to remove */ public void removeVetoPolicyListener(PolicyListener listener); } libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/common/MicrobaComponent.java0000644000175000017500000000432210537216170032331 0ustar gregoagregoapackage com.michaelbaranov.microba.common; import java.awt.Color; import java.util.Collections; import java.util.Map; import javax.swing.JComponent; import javax.swing.UIManager; import javax.swing.plaf.ComponentUI; import com.michaelbaranov.microba.Microba; /** * Superclass for all Microba GUI components. * * @author Michael Baranov * */ public class MicrobaComponent extends JComponent { public static final String PROPERTY_NAME_COLOR_OVERRIDE_MAP = "colorOverrideMap"; static { Microba.init(); } protected Map colorOverrideMap; public ComponentUI getUI() { return ui; } /** * Sets the UI delegate of this component to the corresponding UI delegate * taken from UIManager. *

* This implementation has a workarount to fix the problem with non-standard * class-loaders. */ public void updateUI() { UIManager.getDefaults().put(UIManager.get(this.getUIClassID()), null); ComponentUI delegate = UIManager.getUI(this); setUI(delegate); invalidate(); } /** * Returns per-instance (only for this instance) map of color overrides. May * be null. *

* NOTE: returned map is unmodifiable. Use {@link #setColorOverrideMap(Map)} * to change the map. * * @return keys in the map are {@link String} constants, valuse are of type * {@link Color} or of type {@link String} (in this case, * {@link Color} values are obtained via * {@link UIManager#getColor(Object)}) */ public Map getColorOverrideMap() { if (colorOverrideMap == null) return null; return Collections.unmodifiableMap(colorOverrideMap); } /** * Sets per-instance (only for this instance) map of color overrides. * * @param colorOverrideMap * keys in the map are {@link String} constants, valuse are of * type {@link Color} or of type {@link String} (in this case, * {@link Color} values are obtained via * {@link UIManager#getColor(Object)}). May be null. */ public void setColorOverrideMap(Map colorOverrideMap) { Object old = this.colorOverrideMap; this.colorOverrideMap = colorOverrideMap; firePropertyChange(PROPERTY_NAME_COLOR_OVERRIDE_MAP, old, colorOverrideMap); updateUI(); } } libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/common/AbstractPolicy.java0000644000175000017500000000176210412660742032022 0ustar gregoagregoapackage com.michaelbaranov.microba.common; import javax.swing.event.EventListenerList; /** * This is a convenience implementation of {@link Policy}. * * @author Michael Baranov * */ public abstract class AbstractPolicy implements Policy { private EventListenerList vetoPolicyListenerList = new EventListenerList(); public void addVetoPolicyListener(PolicyListener listener) { vetoPolicyListenerList.add(PolicyListener.class, listener); } public void removeVetoPolicyListener(PolicyListener listener) { vetoPolicyListenerList.remove(PolicyListener.class, listener); } /** * Fires a {@link PolicyEvent} to all related {@link PolicyListener}s. */ protected void fireVetoPolicyChangeAction() { Object[] listeners = vetoPolicyListenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) if (listeners[i] == PolicyListener.class) ((PolicyListener) listeners[i + 1]) .policyChanged(new PolicyEvent(this)); } } libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/common/CommitEvent.java0000644000175000017500000000155610412660742031332 0ustar gregoagregoapackage com.michaelbaranov.microba.common; import java.util.EventObject; /** * An event used to indicate a change to a control has been commited or reverted * (rolled back). * * @author Michael Baranov * */ public class CommitEvent extends EventObject { private boolean commit; /** * Constructor. * * @param source * a control that fired the event * @param commit * true to indicate commit, false * to indicate revert (rollback) */ public CommitEvent(Object source, boolean commit) { super(source); this.commit = commit; } /** * Returns the type of the event. * * @return true if a change has been commited to a control, * false otherwise. */ public boolean isCommit() { return commit; } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/common/AbstractBoundedTableModel.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/common/AbstractBoundedTableMod0000644000175000017500000000423210412660742032626 0ustar gregoagregoapackage com.michaelbaranov.microba.common; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import javax.swing.table.AbstractTableModel; /** * A simple abstract implementation of BoundedTableModel. A * convenience class. * * @author Michael Baranov */ public abstract class AbstractBoundedTableModel extends AbstractTableModel implements BoundedTableModel { private PropertyChangeSupport propertySupport=new PropertyChangeSupport(this); public void addPropertyChangeListener(PropertyChangeListener listener) { propertySupport.addPropertyChangeListener(listener); } public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { propertySupport.addPropertyChangeListener(propertyName, listener); } public void firePropertyChange(PropertyChangeEvent evt) { propertySupport.firePropertyChange(evt); } public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) { propertySupport.firePropertyChange(propertyName, oldValue, newValue); } public void firePropertyChange(String propertyName, int oldValue, int newValue) { propertySupport.firePropertyChange(propertyName, oldValue, newValue); } public void firePropertyChange(String propertyName, Object oldValue, Object newValue) { propertySupport.firePropertyChange(propertyName, oldValue, newValue); } public PropertyChangeListener[] getPropertyChangeListeners() { return propertySupport.getPropertyChangeListeners(); } public PropertyChangeListener[] getPropertyChangeListeners(String propertyName) { return propertySupport.getPropertyChangeListeners(propertyName); } public boolean hasListeners(String propertyName) { return propertySupport.hasListeners(propertyName); } public void removePropertyChangeListener(PropertyChangeListener listener) { propertySupport.removePropertyChangeListener(listener); } public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { propertySupport.removePropertyChangeListener(propertyName, listener); } } libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/common/PolicyListener.java0000644000175000017500000000060310412660742032035 0ustar gregoagregoapackage com.michaelbaranov.microba.common; import java.util.EventListener; /** * A listener that is notified of {@link PolicyEvent} events. * * @author Michael Baranov * */ public interface PolicyListener extends EventListener { /** * Called when a {@link PolicyEvent} is fired. * * @param event */ public void policyChanged(PolicyEvent event); } libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/common/PolicyEvent.java0000644000175000017500000000063410412660742031335 0ustar gregoagregoapackage com.michaelbaranov.microba.common; import java.util.EventObject; /** * An event used to indicate a policy (algorithm) has changed. * * @author Michael Baranov * */ public class PolicyEvent extends EventObject { /** * Constructor. * * @param source * an object whose policy has changed */ public PolicyEvent(Object source) { super(source); } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/common/AbstractBoundedTableModelWithSelection.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/common/AbstractBoundedTableMod0000644000175000017500000000655310412660742032636 0ustar gregoagregoapackage com.michaelbaranov.microba.common; import java.util.EventListener; import javax.swing.DefaultListSelectionModel; import javax.swing.ListSelectionModel; import javax.swing.event.ListSelectionListener; /** * A simple abstract implementation of BoundedTableModel with * implemented ListSelectionModel functionality. A convenience * class. * * @author Michael Baranov * */ public abstract class AbstractBoundedTableModelWithSelection extends AbstractBoundedTableModel implements ListSelectionModel { private DefaultListSelectionModel selection = new DefaultListSelectionModel(); public AbstractBoundedTableModelWithSelection() { super(); } public void addListSelectionListener(ListSelectionListener l) { selection.addListSelectionListener(l); } public void addSelectionInterval(int index0, int index1) { selection.addSelectionInterval(index0, index1); } public void clearSelection() { selection.clearSelection(); } public int getAnchorSelectionIndex() { return selection.getAnchorSelectionIndex(); } public int getLeadSelectionIndex() { return selection.getLeadSelectionIndex(); } public EventListener[] getListeners(Class listenerType) { return selection.getListeners(listenerType); } public ListSelectionListener[] getListSelectionListeners() { return selection.getListSelectionListeners(); } public int getMaxSelectionIndex() { return selection.getMaxSelectionIndex(); } public int getMinSelectionIndex() { return selection.getMinSelectionIndex(); } public int getSelectionMode() { return selection.getSelectionMode(); } public boolean getValueIsAdjusting() { return selection.getValueIsAdjusting(); } public void insertIndexInterval(int index, int length, boolean before) { selection.insertIndexInterval(index, length, before); } public boolean isLeadAnchorNotificationEnabled() { return selection.isLeadAnchorNotificationEnabled(); } public boolean isSelectedIndex(int index) { return selection.isSelectedIndex(index); } public boolean isSelectionEmpty() { return selection.isSelectionEmpty(); } // J2SE5 // //////////////////////////////////////////////////// // public void moveLeadSelectionIndex(int leadIndex) { // selection.moveLeadSelectionIndex(leadIndex); // } public void removeIndexInterval(int index0, int index1) { selection.removeIndexInterval(index0, index1); } public void removeListSelectionListener(ListSelectionListener l) { selection.removeListSelectionListener(l); } public void removeSelectionInterval(int index0, int index1) { selection.removeSelectionInterval(index0, index1); } public void setAnchorSelectionIndex(int anchorIndex) { selection.setAnchorSelectionIndex(anchorIndex); } public void setLeadAnchorNotificationEnabled(boolean flag) { selection.setLeadAnchorNotificationEnabled(flag); } public void setLeadSelectionIndex(int leadIndex) { selection.setLeadSelectionIndex(leadIndex); } public void setSelectionInterval(int index0, int index1) { selection.setSelectionInterval(index0, index1); } public void setSelectionMode(int selectionMode) { selection.setSelectionMode(selectionMode); } public void setValueIsAdjusting(boolean isAdjusting) { selection.setValueIsAdjusting(isAdjusting); } } libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/common/CommitListener.java0000644000175000017500000000057410412660742032035 0ustar gregoagregoapackage com.michaelbaranov.microba.common; import java.util.EventListener; /** * A listener that is notified of {@link CommitEvent} events. * * @author Michael Baranov * */ public interface CommitListener extends EventListener { /** * Called when a {@link CommitEvent} is fired. * * @param event */ public void commit(CommitEvent event); } libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/common/BoundedTableModel.java0000644000175000017500000000324510412660742032406 0ustar gregoagregoapackage com.michaelbaranov.microba.common; import java.beans.PropertyChangeListener; import javax.swing.table.TableModel; /** * An extended TableModel. *

* The upper and lower bound values are introduced to further describe table * data. For example, 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} * * @version 0.1 (rev. 13 Aug 2005) * @author Michael Baranov www.michaelbaranov.com * */ public interface BoundedTableModel extends TableModel { /** * The name of the bound property, that holds lower bound value. */ public static final String PROPERTY_LOWER_BOUND = "lowerBound"; /** * The name of the bound property, that holds upper bound value. */ public static final String PROPERTY_UPPER_BOUND = "upperBound"; /** * Returns some lower bound, further describing the data. * * @return lower bound. */ int getLowerBound(); /** * Returns some upper bound, further describing the data. * * @return upper bound. */ int getUpperBound(); public void addPropertyChangeListener(PropertyChangeListener listener); public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener); public void removePropertyChangeListener(PropertyChangeListener listener); public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener); } libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/Microba.java0000644000175000017500000001313710537216170027162 0ustar gregoagregoapackage com.michaelbaranov.microba; import java.applet.Applet; import java.awt.Color; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.HashMap; import java.util.Map; import javax.swing.LookAndFeel; import javax.swing.UIManager; import com.michaelbaranov.microba.common.MicrobaComponent; /** * This class is used to initialize Microba library. * * @author Michael Baranov * */ public class Microba { private static UIChangeListener changeListener = new UIChangeListener(); /** * Initializes the library: installs L&F properties, sets up a L&F change * listener. *

* No need to call this method explicitly for desktop applications. You * should only call it in {@link Applet#init()}. This will handle browser * refresh button correctly. * */ public static synchronized void init() { setLookAndFeelProperties(UIManager.getLookAndFeel()); UIManager.removePropertyChangeListener(changeListener); UIManager.addPropertyChangeListener(changeListener); } private static synchronized void setLookAndFeelProperties( LookAndFeel lookAndFeel) { if (lookAndFeel == null) return; String packagePrefix = "com.michaelbaranov.microba."; // all L&F UIManager.put("microba.CalendarPaneUI", packagePrefix + "calendar.ui.basic.BasicCalendarPaneUI"); UIManager.put("microba.DatePickerUI", packagePrefix + "calendar.ui.basic.BasicDatePickerUI"); UIManager.put("microba.GradientUI", packagePrefix + "gradient.ui.basic.BasicGradientUI"); UIManager.put("microba.GradientEditorUI", packagePrefix + "gradienteditor.ui.basic.BasicGradientEditorUI"); UIManager.put("microba.MarkerBarUI", packagePrefix + "marker.ui.basic.BasicMarkerBarUI"); // particular L&F if (lookAndFeel.getID().equals("Windows")) { UIManager.put("microba.MarkerBarUI", packagePrefix + "marker.ui.windows.WindowsMarkerBarUI"); } else if (lookAndFeel.getID().equals("Metal")) { UIManager.put("microba.MarkerBarUI", packagePrefix + "marker.ui.metal.MetalMarkerBarUI"); } else if (lookAndFeel.getID().equals("Motif")) { UIManager.put("microba.MarkerBarUI", packagePrefix + "marker.ui.motif.MotifMarkerBarUI"); } } private static final class UIChangeListener implements PropertyChangeListener { public void propertyChange(PropertyChangeEvent event) { if ("lookAndFeel".equals(event.getPropertyName())) { setLookAndFeelProperties((LookAndFeel) event.getNewValue()); } } } private static Map lookAndFeelToOverride = new HashMap(); /** * Sets per-Lokk&Feel map of color overrides. * * * @param lookAndFeel * look&feel ID * @param overrides * keys in the map are {@link String} constants, valuse are of * type {@link Color} or of type {@link String} (in this case, * {@link Color} values are obtained via * {@link UIManager#getColor(Object)}). May be null. */ public static void setColorOverrideMap(String lookAndFeel, Map overrides) { lookAndFeelToOverride.put(lookAndFeel, overrides); // TODO: refresh ui delegates } /** * Returns overriden color for given component in current Look&Feel. The * algorithms is: *

* This method is actually intended to be used by UI delegates of the * library. * * @param colorConstant * color constant * @param component * component of the library * @return overriden color or null if not overriden */ public static synchronized Color getOverridenColor(String colorConstant, MicrobaComponent component) { Map componentOverrideMap = component.getColorOverrideMap(); if (componentOverrideMap != null) { if (componentOverrideMap.containsKey(colorConstant)) { Object val = componentOverrideMap.get(colorConstant); if (val instanceof Color) return (Color) val; else return UIManager.getColor(val); } } String currentLookAndFeel = UIManager.getLookAndFeel().getID(); Map overrides = (Map) lookAndFeelToOverride.get(currentLookAndFeel); if (overrides != null) { if (overrides.containsKey(colorConstant)) { Object val = overrides.get(colorConstant); if (val instanceof Color) return (Color) val; else return UIManager.getColor(val); } } return null; } /** * Returns overriden color for given component in current Look&Feel or a * default value. The algorithms is: * * This method is actually intended to be used by UI delegates of the * library. * * @param colorConstant * color constant * @param component * component of the library * @param defaultColor * @return overriden color or defaultColor if not overriden */ public static synchronized Color getOverridenColor(String colorConstant, MicrobaComponent component, Color defaultColor) { Color overriden = getOverridenColor(colorConstant, component); if (overriden != null) return overriden; else return defaultColor; } } libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/0000755000175000017500000000000010763713760026517 5ustar gregoagregoalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/DatePicker.java0000644000175000017500000002472410537216170031376 0ustar gregoagregoapackage com.michaelbaranov.microba.calendar; import java.text.DateFormat; import java.util.Date; import java.util.Locale; import java.util.Map; import java.util.TimeZone; import com.michaelbaranov.microba.calendar.ui.DatePickerUI; /** * A concrete implementation of JComponent. Capable of displaying and selecting * dates, much like an editable combo-box with a calendar dropdown. *

* This implementatin allows for specifying time component along with the date. * Make sure that: 1) keepTime property is true; 2) stripTime is false; 3) * dateFormat has time fields; * * @author Michael Baranov */ public class DatePicker extends CalendarPane { /** * The name of a "dateFormat" property. */ public static final String PROPERTY_NAME_DATE_FORMAT = "dateFormat"; /** * The name of a "fieldEditable" property. */ public static final String PROPERTY_NAME_FIELD_EDITABLE = "fieldEditable"; /** * The name of a "keepTime" property. */ public static final String PROPERTY_NAME_KEEP_TIME = "keepTime"; /** * The name of a "pickerStyle" property. */ public static final String PROPERTY_NAME_PICKER_STYLE = "pickerStyle"; /** * The name of a "popupFocusable" property. */ public static final String PROPERTY_NAME_DROPDOWN_FOCUSABLE = "dropdownFocusable"; /** * A constant for the "pickerStyle" property. */ public static final int PICKER_STYLE_FIELD_AND_BUTTON = 0x110; /** * A constant for the "pickerStyle" property. */ public static final int PICKER_STYLE_BUTTON = 0x120; private static final String uiClassID = "microba.DatePickerUI"; private DateFormat dateFormat; private boolean fieldEditable; private boolean keepTime; private int pickerStyle; private boolean dropdownFocusable; /** * Constructor. */ public DatePicker() { this(new Date(), DateFormat.MEDIUM, Locale.getDefault(), TimeZone .getDefault()); } /** * Constructor. */ public DatePicker(Date initialDate) { this(initialDate, DateFormat.MEDIUM, Locale.getDefault(), TimeZone .getDefault()); } /** * Constructor. */ public DatePicker(Date initialDate, int dateStyle) { this(initialDate, dateStyle, Locale.getDefault(), TimeZone.getDefault()); } /** * Constructor. */ public DatePicker(Date initialDate, DateFormat dateFormat) { this(initialDate, dateFormat, Locale.getDefault(), TimeZone .getDefault()); } /** * Constructor. */ public DatePicker(Date initialDate, int dateStyle, Locale locale) { this(initialDate, dateStyle, locale, TimeZone.getDefault()); } /** * Constructor. */ public DatePicker(Date initialDate, DateFormat dateFormat, Locale locale) { this(initialDate, dateFormat, locale, TimeZone.getDefault()); } /** * Constructor. */ public DatePicker(Date initialDate, int dateStyle, Locale locale, TimeZone zone) { super(initialDate, CalendarPane.STYLE_CLASSIC, locale, zone); checkDateStyle(dateStyle); this.dateFormat = dateFormatFromStyle(dateStyle); this.fieldEditable = true; this.keepTime = true; this.pickerStyle = PICKER_STYLE_FIELD_AND_BUTTON; this.setStripTime(false); this.dropdownFocusable = true; updateUI(); } /** * Constructor. */ public DatePicker(Date initialDate, DateFormat dateFormat, Locale locale, TimeZone zone) { super(initialDate, CalendarPane.STYLE_CLASSIC, locale, zone); checkDateFormat(dateFormat); this.dateFormat = dateFormat; this.fieldEditable = true; this.keepTime = true; this.pickerStyle = PICKER_STYLE_FIELD_AND_BUTTON; this.setStripTime(false); this.dropdownFocusable = true; updateUI(); } public String getUIClassID() { return uiClassID; } /** * Returns the date format. *

* * @return current date format * @see #setDateFormat(DateFormat) */ public DateFormat getDateFormat() { return dateFormat; } /** * Sets the date format constant defined by {@link DateFormat} and updates * the control to reflect new date style. *

* * @param dateFormat * the date format constant to set * @see #getDateFormat() * @see DateFormat */ public void setDateFormat(DateFormat dateFormat) { checkDateFormat(dateFormat); Object oldValue = this.dateFormat; this.dateFormat = dateFormat; firePropertyChange(PROPERTY_NAME_DATE_FORMAT, oldValue, dateFormat); } /** * Is the edit field of the control editable by the user? *

* If not editable, the user can not type in the date and can only use * calendar drop-down to select dates. * * @return true if the edit field is editable, * false otherwise * * @see #setFieldEditable(boolean) */ public boolean isFieldEditable() { return fieldEditable; } /** * Enables or disables editing of the edit field by the user. *

* If not editable, the user can not type in the date and can only use * calendar drop-down to select dates. * * @param fieldEditable * the editable value to set * * @see #isFieldEditable() */ public void setFieldEditable(boolean fieldEditable) { boolean old = this.fieldEditable; this.fieldEditable = fieldEditable; firePropertyChange(PROPERTY_NAME_FIELD_EDITABLE, old, fieldEditable); } /** * Is the dropdown focusable? *

* If not focusable, the dropdown calendar will lack some keyboard input * capabilities. * * @return true if the dropdown is focusable, * false otherwise * * @see #setDropdownFocusable(boolean) */ public boolean isDropdownFocusable() { return dropdownFocusable; } /** * Enables or disables focusability of the dropdown calendar. *

* If not focusable, the dropdown calendar will lack some keyboard input * capabilities. * * @param popupFocusable * the focusable value to set * * @see #isDropdownFocusable() */ public void setDropdownFocusable(boolean popupFocusable) { boolean old = this.dropdownFocusable; this.dropdownFocusable = popupFocusable; firePropertyChange(PROPERTY_NAME_DROPDOWN_FOCUSABLE, old, popupFocusable); } /** * Does UI try to preserve time components entered in the edit field? *

* If true and if the date format has some time fields * (hours, minutes, seconds, fraction of second), the UI tries to respect * the time fields' values entered by user as much as possible. *

* Note: to be able to receive time portion of the date, make sure * {@link #isStripTime()} is false (the dafualt). * * @return true if the UI respects time fields, * false otherwise * @see #setKeepTime(boolean) * @see #setStripTime(boolean) * @see #isStripTime() * */ public boolean isKeepTime() { return keepTime; } /** * Determines if the UI should try to preserve time components entered in * the edit field. *

* If true and if the date format has some time fields * (hours, minutes, seconds, fraction of second), the UI tries to respect * the time fields' values entered by user as much as possible. *

* Note: to be able to receive time portion of the date, make sure * {@link #isStripTime()} is false (the dafualt). * * @param keepTime * true to make the UI respects time fields, * false otherwise * @see #isKeepTime() * @see #setStripTime(boolean) * @see #isStripTime() */ public void setKeepTime(boolean keepTime) { boolean old = this.keepTime; this.keepTime = keepTime; firePropertyChange(PROPERTY_NAME_KEEP_TIME, old, keepTime); } /** * Returns current visual style of the picker control. *

* NOTE: do not confuse with {@link #getStyle()}. * * @return current visual style constant. */ public int getPickerStyle() { return pickerStyle; } /** * Sets the current visual style of the picker control. *

* The control is then updated to reflect the new style. *

* NOTE: do not confuse with {@link #getStyle()}. * * @param pickerStyle * the style to set * @see #PICKER_STYLE_BUTTON * @see #PICKER_STYLE_FIELD_AND_BUTTON */ public void setPickerStyle(int pickerStyle) { pickerStyle = checkPickerStyle(pickerStyle); int oldValue = this.pickerStyle; this.pickerStyle = pickerStyle; firePropertyChange(PROPERTY_NAME_PICKER_STYLE, oldValue, pickerStyle); } /** * A shortucut method to switch picker style between * {@link #PICKER_STYLE_FIELD_AND_BUTTON} and {@link #PICKER_STYLE_BUTTON} * * @param buttonOnly * true to set {@link #PICKER_STYLE_BUTTON}, * false to set * {@link #PICKER_STYLE_FIELD_AND_BUTTON} */ public void showButtonOnly(boolean buttonOnly) { if (buttonOnly) setPickerStyle(PICKER_STYLE_BUTTON); else setPickerStyle(PICKER_STYLE_FIELD_AND_BUTTON); } /** * Displays the calendar dropdown. */ public void showPopup() { ((DatePickerUI) getUI()).showPopup(true); } /** * Hides the calendar dropdown without selecting a date. */ public void hidePopup() { ((DatePickerUI) getUI()).showPopup(false); } public boolean commitEdit() { try { ((DatePickerUI) getUI()).commit(); fireCommitEvent(true); return true; } catch (Exception e) { return false; } } public void revertEdit() { ((DatePickerUI) getUI()).revert(); fireCommitEvent(false); } private void checkDateStyle(int style) { if (style != DateFormat.SHORT && style != DateFormat.MEDIUM && style != DateFormat.LONG) throw new IllegalArgumentException("dateStyle: unrecognized style"); } private int checkPickerStyle(int style) { if (style == 0) style = PICKER_STYLE_FIELD_AND_BUTTON; if (style != PICKER_STYLE_FIELD_AND_BUTTON && style != PICKER_STYLE_BUTTON) throw new IllegalArgumentException(PROPERTY_NAME_PICKER_STYLE + ": unrecognized style"); return style; } private void checkDateFormat(DateFormat dateFormat) { if (dateFormat == null) throw new IllegalArgumentException("dateFormat: null value"); } private DateFormat dateFormatFromStyle(int dateStyle) { DateFormat df = DateFormat.getDateInstance(dateStyle, this.getLocale()); df.setTimeZone(this.getZone()); return df; } } libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/0000755000175000017500000000000010634142132027116 5ustar gregoagregoalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/DatePickerUI.java0000644000175000017500000000033410412660742032240 0ustar gregoagregoapackage com.michaelbaranov.microba.calendar.ui; public abstract class DatePickerUI extends CalendarPaneUI { public abstract void showPopup(boolean visible); public abstract void setSimpeLook(boolean b); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/CalendarPaneUI.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/CalendarPaneUI.jav0000644000175000017500000000063211050305306032371 0ustar gregoagregoapackage com.michaelbaranov.microba.calendar.ui; import java.beans.PropertyVetoException; import java.text.ParseException; import javax.swing.plaf.ComponentUI; public abstract class CalendarPaneUI extends ComponentUI { public abstract void commit() throws PropertyVetoException, ParseException; public abstract void revert(); public abstract void observeMonth(int year, int month); } libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/0000755000175000017500000000000010634142132030177 5ustar gregoagregoa././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/BasicCalendarPaneUI.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/BasicCalenda0000644000175000017500000003365711050603126032427 0ustar gregoagregoapackage com.michaelbaranov.microba.calendar.ui.basic; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import java.awt.event.KeyEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.beans.PropertyVetoException; import java.util.Date; import java.util.HashSet; import java.util.Locale; import java.util.Set; import java.util.TimeZone; import javax.swing.AbstractAction; import javax.swing.ActionMap; import javax.swing.InputMap; import javax.swing.JComponent; import javax.swing.KeyStroke; import javax.swing.SwingUtilities; import javax.swing.plaf.ComponentUI; import com.michaelbaranov.microba.calendar.CalendarPane; import com.michaelbaranov.microba.calendar.DatePicker; import com.michaelbaranov.microba.calendar.HolidayPolicy; import com.michaelbaranov.microba.calendar.VetoPolicy; import com.michaelbaranov.microba.calendar.ui.CalendarPaneUI; public class BasicCalendarPaneUI extends CalendarPaneUI implements PropertyChangeListener, FocusListener { protected static final String ESCAPE_KEY = "##CalendarPaneUI.escape##"; protected static final String ENTER_KEY = "##CalendarPaneUI.enter##"; protected CalendarPane peer; protected ClassicCalendarPanel classicPanel; protected ModernCalendarPanel modernPanel; protected AuxPanel auxPanel; protected CalendarGridPanel gridPanel; protected CalendarNumberOfWeekPanel numberOfWeekPanel; protected CalendarHeader headerPanel; protected Set focusableComponents = new HashSet(); protected ComponentListener componentListener; public static ComponentUI createUI(JComponent c) { return new BasicCalendarPaneUI(); } public void installUI(JComponent component) { peer = (CalendarPane) component; createNestedComponents(); addNestedComponents(); installListeners(); installKeyboardActions(); } public void uninstallUI(JComponent component) { uninstallKeyboardActions(); uninstallListeners(); removeNestedComponents(); destroyNestedComponents(); peer = null; } protected void uninstallKeyboardActions() { InputMap input = peer .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); ActionMap action = peer.getActionMap(); input.remove(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)); input.remove(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)); action.remove(ENTER_KEY); action.remove(ESCAPE_KEY); } protected void installKeyboardActions() { InputMap input = peer .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); ActionMap action = peer.getActionMap(); input.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), ENTER_KEY); input.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), ESCAPE_KEY); input.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0), "pgupkey"); input .put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0), "pgdownkey"); action.put(ENTER_KEY, new AbstractAction() { public void actionPerformed(ActionEvent e) { peer.commitEdit(); } }); action.put(ESCAPE_KEY, new AbstractAction() { public void actionPerformed(ActionEvent e) { peer.revertEdit(); } }); action.put("pgupkey", new AbstractAction() { public void actionPerformed(ActionEvent e) { classicPanel.addMonth(1); } }); action.put("pgdownkey", new AbstractAction() { public void actionPerformed(ActionEvent e) { classicPanel.addMonth(-1); } }); } protected void uninstallListeners() { peer.removePropertyChangeListener(this); peer.removeFocusListener(this); } protected void installListeners() { peer.addPropertyChangeListener(this); peer.addFocusListener(this); } protected void createNestedComponents() { Date baseDate = peer.getDate() == null ? new Date() : peer.getDate(); classicPanel = new ClassicCalendarPanel(baseDate, peer.getLocale(), peer.getZone()); modernPanel = new ModernCalendarPanel(baseDate, peer.getLocale(), peer .getZone()); headerPanel = new CalendarHeader(peer, baseDate, peer.getLocale(), peer .getZone(), peer.getHolidayPolicy()); auxPanel = new AuxPanel(peer.getLocale(), peer.getZone(), peer .getVetoPolicy(), peer.isShowTodayButton(), peer .isShowNoneButton(), peer.getResources()); gridPanel = new CalendarGridPanel(peer, peer.getDate(), peer .getLocale(), peer.getZone(), peer.getVetoPolicy(), peer .getHolidayPolicy()); numberOfWeekPanel = new CalendarNumberOfWeekPanel(peer.getDate(), peer .getLocale(), peer.getZone()); focusableComponents.addAll(classicPanel.getFocusableComponents()); focusableComponents.addAll(modernPanel.getFocusableComponents()); focusableComponents.addAll(auxPanel.getFocusableComponents()); focusableComponents.addAll(gridPanel.getFocusableComponents()); focusableComponents.addAll(auxPanel.getFocusableComponents()); componentListener = new ComponentListener(); for (int i = 0; i < focusableComponents.size(); i++) ((JComponent) focusableComponents.toArray()[i]) .addFocusListener(componentListener); gridPanel.addPropertyChangeListener(componentListener); modernPanel.addPropertyChangeListener(componentListener); classicPanel.addPropertyChangeListener(componentListener); auxPanel.addPropertyChangeListener(componentListener); classicPanel.setEnabled(peer.isEnabled()); modernPanel.setEnabled(peer.isEnabled()); headerPanel.setEnabled(peer.isEnabled()); auxPanel.setEnabled(peer.isEnabled()); numberOfWeekPanel.setEnabled(peer.isEnabled()); gridPanel.setEnabled(peer.isEnabled()); } protected void destroyNestedComponents() { gridPanel.removePropertyChangeListener(componentListener); modernPanel.removePropertyChangeListener(componentListener); classicPanel.removePropertyChangeListener(componentListener); auxPanel.removePropertyChangeListener(componentListener); componentListener = null; for (int i = 0; i < focusableComponents.size(); i++) ((JComponent) focusableComponents.toArray()[i]) .removeFocusListener(componentListener); focusableComponents.clear(); classicPanel = null; modernPanel = null; headerPanel = null; auxPanel = null; gridPanel = null; numberOfWeekPanel = null; } protected void addNestedComponents() { peer.removeAll(); peer.setLayout(new GridBagLayout()); if ((peer.getStyle() & CalendarPane.STYLE_CLASSIC) > 0) { peer.add(classicPanel, new GridBagConstraints(0, 0, 2, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); } else { peer.add(modernPanel, new GridBagConstraints(0, 0, 2, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); } peer.add(headerPanel, new GridBagConstraints(1, 1, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); if (peer.isShowNumberOfWeek()) { peer.add(numberOfWeekPanel, new GridBagConstraints(0, 2, 1, 1, 0, 1, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0)); } peer.add(gridPanel, new GridBagConstraints(1, 2, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets( 0, 0, 0, 0), 0, 0)); if (peer.isShowTodayButton()) { peer.add(auxPanel, new GridBagConstraints(0, 3, 2, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); } if (peer.isShowNumberOfWeek()) { // TODO: } peer.revalidate(); peer.repaint(); } protected void removeNestedComponents() { peer.removeAll(); } protected void widgetDateChanged(Date date) { Date baseDate = date == null ? new Date() : date; headerPanel.setDate(baseDate); classicPanel.setDate(baseDate); modernPanel.setDate(baseDate); gridPanel.setBaseDate(baseDate); gridPanel.setDate(date); numberOfWeekPanel.setBaseDate(baseDate); } protected void widgetLocaleChanged(Locale newValue) { classicPanel.setLocale(newValue); modernPanel.setLocale(newValue); gridPanel.setLocale(newValue); headerPanel.setLocale(newValue); auxPanel.setLocale(newValue); numberOfWeekPanel.setLocale(newValue); } protected void widgetZoneChanged(TimeZone zone) { classicPanel.setZone(zone); modernPanel.setZone(zone); gridPanel.setZone(zone); headerPanel.setZone(zone); auxPanel.setZone(zone); numberOfWeekPanel.setZone(zone); } protected void widgetResourceChanged() { auxPanel.setResources(peer.getResources()); } public void commit() throws PropertyVetoException { peer.setDate(gridPanel.getDateToCommit()); } public void revert() { widgetDateChanged(peer.getDate()); } public void focusGained(FocusEvent e) { gridPanel.requestFocus(true); } public void focusLost(FocusEvent e) { } public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals(CalendarPane.PROPERTY_NAME_DATE)) { widgetDateChanged((Date) evt.getNewValue()); } else if (evt.getPropertyName().equals( CalendarPane.PROPERTY_NAME_LOCALE)) { widgetLocaleChanged((Locale) evt.getNewValue()); } else if (evt.getPropertyName() .equals(CalendarPane.PROPERTY_NAME_ZONE)) { widgetZoneChanged((TimeZone) evt.getNewValue()); } else if (evt.getPropertyName().equals( CalendarPane.PROPERTY_NAME_VETO_POLICY)) { gridPanel.setVetoPolicy((VetoPolicy) evt.getNewValue()); auxPanel.setVetoModel((VetoPolicy) evt.getNewValue()); } else if (evt.getPropertyName().equals( CalendarPane.PROPERTY_NAME_HOLIDAY_POLICY)) { gridPanel.setHolidayPolicy((HolidayPolicy) evt.getNewValue()); headerPanel.setHolidayPolicy((HolidayPolicy) evt.getNewValue()); } else if (evt.getPropertyName().equals("enabled")) { boolean value = ((Boolean) evt.getNewValue()).booleanValue(); classicPanel.setEnabled(value); modernPanel.setEnabled(value); headerPanel.setEnabled(value); auxPanel.setEnabled(value); numberOfWeekPanel.setEnabled(value); gridPanel.setEnabled(value); } else if (evt.getPropertyName().equals( CalendarPane.PROPERTY_NAME_STYLE)) { addNestedComponents(); } else if (evt.getPropertyName().equals( CalendarPane.PROPERTY_NAME_SHOW_TODAY_BTN)) { Boolean value = (Boolean) evt.getNewValue(); auxPanel.setShowTodayBtn(value.booleanValue()); } else if (evt.getPropertyName().equals( DatePicker.PROPERTY_NAME_SHOW_NONE_BTN)) { boolean value = ((Boolean) evt.getNewValue()).booleanValue(); auxPanel.setShowNoneButton(value); } else if (evt.getPropertyName().equals( DatePicker.PROPERTY_NAME_SHOW_NUMBER_WEEK)) { addNestedComponents(); } else if (evt.getPropertyName().equals("focusable")) { Boolean value = (Boolean) evt.getNewValue(); classicPanel.setFocusable(value.booleanValue()); modernPanel.setFocusable(value.booleanValue()); gridPanel.setFocusable(value.booleanValue()); auxPanel.setFocusable(value.booleanValue()); } else if (evt.getPropertyName().equals( CalendarPane.PROPERTY_NAME_RESOURCES)) { widgetResourceChanged(); } else if (evt.getPropertyName().equals("enabled"/* * CalendarPane.PROPERTY_NAME_ENABLED */)) { Boolean value = (Boolean) evt.getNewValue(); classicPanel.setEnabled(value.booleanValue()); modernPanel.setEnabled(value.booleanValue()); gridPanel.setEnabled(value.booleanValue()); auxPanel.setEnabled(value.booleanValue()); } } protected class ComponentListener implements FocusListener, PropertyChangeListener { public void focusGained(FocusEvent e) { } public void focusLost(FocusEvent e) { boolean isFocusableComponent = focusableComponents.contains(e .getSource()); boolean isNonEmptyOpposite = e.getOppositeComponent() != null; if (isFocusableComponent && isNonEmptyOpposite && !SwingUtilities.isDescendingFrom(e .getOppositeComponent(), peer)) { peer.commitOrRevert(); } } public void propertyChange(PropertyChangeEvent evt) { if (evt.getSource() == gridPanel && evt.getPropertyName().equals( CalendarGridPanel.PROPERTY_NAME_DATE)) { Date newValue = (Date) evt.getNewValue(); try { peer.setDate(newValue); } catch (PropertyVetoException e) { // Ignore. Just can not happen, beacause CalendarGridPanel // already checked the date against current peer's // vetoPolicy. } } if (evt.getSource() == gridPanel && evt .getPropertyName() .equals( CalendarGridPanel.PROPERTY_NAME_NOTIFY_SELECTED_DATE_CLICKED)) { peer.fireActionEvent(); } if (evt.getSource() == gridPanel && evt.getPropertyName().equals( CalendarGridPanel.PROPERTY_NAME_BASE_DATE)) { Date newValue = (Date) evt.getNewValue(); modernPanel.setDate(newValue); classicPanel.setDate(newValue); } if (evt.getSource() == modernPanel && evt.getPropertyName().equals( ModernCalendarPanel.PROPERTY_NAME_DATE)) { Date newValue = (Date) evt.getNewValue(); gridPanel.setBaseDate(newValue); classicPanel.setDate(newValue); numberOfWeekPanel.setBaseDate(newValue); } if (evt.getSource() == classicPanel && evt.getPropertyName().equals( ModernCalendarPanel.PROPERTY_NAME_DATE)) { Date newValue = (Date) evt.getNewValue(); gridPanel.setBaseDate(newValue); modernPanel.setDate(newValue); numberOfWeekPanel.setBaseDate(newValue); } if (evt.getSource() == auxPanel && evt.getPropertyName() .equals(AuxPanel.PROPERTY_NAME_DATE)) { Date date = (Date) evt.getNewValue(); gridPanel.setDate(date); peer.commitEdit(); } } } public void observeMonth(int year, int month) { modernPanel.goToMonth(year, month); } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/CalendarNumberOfWeekPanel.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/CalendarNumb0000644000175000017500000000622310517524646032476 0ustar gregoagregoapackage com.michaelbaranov.microba.calendar.ui.basic; import java.awt.Color; import java.awt.Dimension; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.GridLayout; import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.TimeZone; import javax.swing.BorderFactory; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.UIManager; public class CalendarNumberOfWeekPanel extends JPanel /* * implements * PropertyChangeListener */{ public static final String PROPERTY_NAME_BASE_DATE = "baseDate"; public static final String PROPERTY_NAME_LOCALE = "locale"; public static final String PROPERTY_NAME_ZONE = "zone"; private Color backgroundColorActive = UIManager.getColor("activeCaption"); private Color backgroundColorInactive = UIManager .getColor("inactiveCaption"); private Date baseDate; private Locale locale; private TimeZone zone; private JLabel[] labels = new JLabel[6]; public CalendarNumberOfWeekPanel(Date baseDate, Locale locale, TimeZone timeZone) { super(); this.baseDate = baseDate == null ? new Date() : baseDate; this.locale = locale; this.zone = timeZone; setLayout(new GridLayout(6, 1, 2, 2)); for (int i = 0; i < 6; i++) { JLabel l = new JLabel(); labels[i] = l; add(l); } setBorder(BorderFactory.createEmptyBorder(1, 4, 1, 4)); reflectBaseDate(); } public void setBaseDate(Date baseDate) { this.baseDate = baseDate; reflectBaseDate(); } private void reflectBaseDate() { Calendar calendar = getCalendar(baseDate); calendar.set(Calendar.DAY_OF_MONTH, 1); int skipBefore = calendar.get(Calendar.DAY_OF_WEEK) - calendar.getFirstDayOfWeek(); if (skipBefore < 0) skipBefore = 7 + skipBefore; int activeDays = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); int numActiveWeeks = (activeDays + skipBefore) / 7; if ((activeDays + skipBefore) % 7 > 0) numActiveWeeks++; int startWeek = calendar.get(Calendar.WEEK_OF_YEAR); for (int i = 0; i < 6; i++) { labels[i].setText(startWeek > 0 && numActiveWeeks > 0 ? String .valueOf(startWeek) : ""); labels[i].setForeground(isEnabled() ? UIManager .getColor("controlText") : UIManager .getColor("textInactiveText")); startWeek++; numActiveWeeks--; } setBackground(isEnabled() ? backgroundColorActive : backgroundColorInactive); } private Calendar getCalendar(Date date) { Calendar c = Calendar.getInstance(zone, locale); c.setTime(date); return c; } public void setLocale(Locale locale) { this.locale = locale; reflectBaseDate(); } public void setZone(TimeZone zone) { this.zone = zone; reflectBaseDate(); } public void paint(Graphics g) { FontMetrics fm = g.getFontMetrics(labels[0].getFont()); Dimension dimension = new Dimension(fm.stringWidth("00") + 8, 1); setMinimumSize(dimension); setPreferredSize(dimension); super.paint(g); } public void setEnabled(boolean enabled) { super.setEnabled(enabled); reflectBaseDate(); } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/YearSpinnerModel.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/YearSpinnerM0000644000175000017500000001002710412660742032504 0ustar gregoagregoapackage com.michaelbaranov.microba.calendar.ui.basic; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.TimeZone; import javax.swing.SpinnerNumberModel; class YearSpinnerModel extends SpinnerNumberModel { public static final String PROPERTY_NAME_LOCALE = "locale"; public static final String PROPERTY_NAME_DATE = "date"; public static final String PROPERTY_NAME_ZONE = "zone"; private PropertyChangeSupport changeSupport = new PropertyChangeSupport( this); private Locale locale; private TimeZone zone; private Calendar calendar; public YearSpinnerModel(Date date, Locale locale, TimeZone zone) { this.locale = locale; this.zone = zone; createLocaleAndZoneSensitive(); calendar.setTime(date); } private void createLocaleAndZoneSensitive() { if (calendar != null) { Date old = calendar.getTime(); calendar = Calendar.getInstance(zone, locale); calendar.setTime(old); } else calendar = Calendar.getInstance(zone, locale); } public Object getValue() { return new Integer(calendar.get(Calendar.YEAR)); } public void setValue(Object value) { Number newVal = (Number) value; Number oldVal = (Number) getValue(); if (oldVal.longValue() != newVal.longValue()) { int diff = newVal.intValue() - oldVal.intValue(); int sign = diff > 0 ? 1 : -1; if (diff < 0) diff = -diff; Date oldDate = calendar.getTime(); for (int i = 0; i < diff; i++) calendar.add(Calendar.YEAR, sign); changeSupport.firePropertyChange(PROPERTY_NAME_DATE, oldDate, getDate()); fireStateChanged(); } } public Object getNextValue() { Integer currVal = (Integer) getValue(); int newVal = currVal.intValue() + 1; if (newVal <= calendar.getActualMaximum(Calendar.YEAR)) return new Integer(newVal); return currVal; } public Object getPreviousValue() { Integer currVal = (Integer) getValue(); int newVal = currVal.intValue() - 1; if (newVal >= calendar.getActualMinimum(Calendar.YEAR)) return new Integer(newVal); return currVal; } public Date getDate() { return calendar.getTime(); } public void setDate(Date date) { Date old = calendar.getTime(); if (!old.equals(date)) { calendar.setTime(date); changeSupport.firePropertyChange(PROPERTY_NAME_DATE, old, date); fireStateChanged(); } } public Locale getLocale() { return locale; } public void setLocale(Locale locale) { Locale old = this.locale; this.locale = locale; createLocaleAndZoneSensitive(); changeSupport.firePropertyChange(PROPERTY_NAME_LOCALE, old, locale); fireStateChanged(); } public TimeZone getZone() { return zone; } public void setZone(TimeZone zone) { TimeZone old = this.zone; this.zone = zone; createLocaleAndZoneSensitive(); changeSupport.firePropertyChange(PROPERTY_NAME_LOCALE, old, locale); fireStateChanged(); } public void addPropertyChangeListener(PropertyChangeListener listener) { changeSupport.addPropertyChangeListener(listener); } public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { changeSupport.addPropertyChangeListener(propertyName, listener); } public void removePropertyChangeListener(PropertyChangeListener listener) { changeSupport.removePropertyChangeListener(listener); } public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { changeSupport.removePropertyChangeListener(propertyName, listener); } public PropertyChangeListener[] getPropertyChangeListeners() { return changeSupport.getPropertyChangeListeners(); } public PropertyChangeListener[] getPropertyChangeListeners( String propertyName) { return changeSupport.getPropertyChangeListeners(propertyName); } public boolean hasListeners(String propertyName) { return changeSupport.hasListeners(propertyName); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/CalendarHeader.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/CalendarHead0000644000175000017500000001036210537216170032425 0ustar gregoagregoapackage com.michaelbaranov.microba.calendar.ui.basic; import java.awt.Color; import java.awt.Font; import java.awt.GridLayout; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.TimeZone; import javax.swing.BorderFactory; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingConstants; import javax.swing.UIManager; import com.michaelbaranov.microba.Microba; import com.michaelbaranov.microba.calendar.CalendarPane; import com.michaelbaranov.microba.calendar.HolidayPolicy; class CalendarHeader extends JPanel { private Locale locale; private TimeZone zone; private Date date; private HolidayPolicy holidayPolicy; private Color backgroundColorActive; private Color backgroundColorInactive; private Color foregroundColorActive; private Color foregroundColorInactive; private Color foregroundColorWeekendEnabled; private Color foregroundColorWeekendDisabled; public CalendarHeader(CalendarPane peer, Date date, Locale locale, TimeZone zone, HolidayPolicy holidayPolicy) { super(); backgroundColorActive = Microba.getOverridenColor( CalendarPane.COLOR_CALENDAR_HEADER_BACKGROUND_ENABLED, peer, UIManager.getColor("activeCaption")); backgroundColorInactive = Microba.getOverridenColor( CalendarPane.COLOR_CALENDAR_HEADER_BACKGROUND_DISABLED, peer, UIManager.getColor("inactiveCaption")); foregroundColorActive = Microba.getOverridenColor( CalendarPane.COLOR_CALENDAR_HEADER_FOREGROUND_ENABLED, peer, UIManager.getColor("controlText")); foregroundColorInactive = Microba.getOverridenColor( CalendarPane.COLOR_CALENDAR_HEADER_FOREGROUND_DISABLED, peer, UIManager.getColor("textInactiveText")); foregroundColorWeekendEnabled = Microba.getOverridenColor( CalendarPane.COLOR_CALENDAR_HEADER_FOREGROUND_WEEKEND_ENABLED, peer, Color.RED); foregroundColorWeekendDisabled = Microba.getOverridenColor( CalendarPane.COLOR_CALENDAR_HEADER_FOREGROUND_WEEKEND_DISABLED, peer, foregroundColorInactive); this.locale = locale; this.zone = zone; this.date = date; this.holidayPolicy = holidayPolicy; reflectData(); } private void reflectData() { Calendar cal = Calendar.getInstance(zone, locale); cal.setTime(date == null ? new Date() : date); SimpleDateFormat fmt = new SimpleDateFormat("E", locale); fmt.setTimeZone(zone); int numDaysInWeek = cal.getActualMaximum(Calendar.DAY_OF_WEEK) - cal.getActualMinimum(Calendar.DAY_OF_WEEK) + 1; int firstDayOfWeek = cal.getFirstDayOfWeek(); cal.set(Calendar.DAY_OF_WEEK, firstDayOfWeek); removeAll(); setLayout(new GridLayout(1, numDaysInWeek, 2, 2)); setBackground(isEnabled() ? backgroundColorActive : backgroundColorInactive); for (int i = 0; i < numDaysInWeek; i++) { JLabel label = new JLabel(); // TODO: add option to control limit length: label.setText(fmt.format(cal.getTime())/* .substring(0,1) */); label.setForeground(isEnabled() ? foregroundColorActive : foregroundColorInactive); label.setHorizontalAlignment(SwingConstants.CENTER); label.setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 0)); Font boldFont = label.getFont().deriveFont(Font.BOLD); label.setFont(boldFont); add(label); boolean isHolliday = false; if (holidayPolicy != null) { isHolliday = holidayPolicy.isWeekend(this, cal); } if (isHolliday) label.setForeground(isEnabled() ? foregroundColorWeekendEnabled : foregroundColorWeekendDisabled); cal.add(Calendar.DAY_OF_WEEK, 1); } setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 1)); revalidate(); repaint(); } public void setLocale(Locale locale) { this.locale = locale; reflectData(); } public void setDate(Date date) { this.date = date; reflectData(); } public TimeZone getZone() { return zone; } public void setZone(TimeZone zone) { this.zone = zone; reflectData(); } public void setHolidayPolicy(HolidayPolicy holidayPolicy) { this.holidayPolicy = holidayPolicy; reflectData(); } public void setEnabled(boolean enabled) { super.setEnabled(enabled); reflectData(); } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/ClassicCalendarPanel.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/ClassicCalen0000644000175000017500000001723610517524646032475 0ustar gregoagregoapackage com.michaelbaranov.microba.calendar.ui.basic; import java.awt.Dimension; import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Collection; import java.util.Date; import java.util.HashSet; import java.util.Locale; import java.util.Set; import java.util.TimeZone; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingConstants; import com.michaelbaranov.microba.calendar.resource.Resource; class ClassicCalendarPanel extends JPanel implements PropertyChangeListener { public static final String PROPERTY_NAME_DATE = "date"; public static final String PROPERTY_NAME_LOCALE = "locale"; public static final String PROPERTY_NAME_ZONE = "zone"; private Locale locale; private TimeZone zone; private Calendar calendar; private JButton prevButton; private JButton nextButton; private JLabel selectedDateLabel; private DateFormat format; private Set focusableComponents = new HashSet(); private JButton fastPrevButton; private JButton fastNextButton; public ClassicCalendarPanel(Date aDate, Locale aLocale, TimeZone zone) { this.locale = aLocale; this.zone = zone; prevButton = new JButton(); nextButton = new JButton(); fastPrevButton = new JButton(); fastNextButton = new JButton(); nextButton.setIcon(new ImageIcon(Resource.class.getResource("forward-16.png"))); prevButton.setIcon(new ImageIcon(Resource.class.getResource("back-16.png"))); fastNextButton.setIcon(new ImageIcon(Resource.class.getResource("forward-fast-16.png"))); fastPrevButton.setIcon(new ImageIcon(Resource.class.getResource("back-fast-16.png"))); prevButton.setMargin(new Insets(0, 0, 0, 0)); nextButton.setMargin(new Insets(0, 0, 0, 0)); fastPrevButton.setMargin(new Insets(0, 0, 0, 0)); fastNextButton.setMargin(new Insets(0, 0, 0, 0)); Dimension psz = nextButton.getPreferredSize(); Dimension npsz = new Dimension(psz.height, psz.height); nextButton.setPreferredSize(npsz); prevButton.setPreferredSize(npsz); selectedDateLabel = new JLabel(); selectedDateLabel.setHorizontalAlignment(SwingConstants.CENTER); selectedDateLabel.setFont(selectedDateLabel.getFont().deriveFont( Font.BOLD)); setLayout(new GridBagLayout()); add(fastPrevButton, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets( 0, 0, 3, 0), 0, 0)); add(prevButton, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets( 0, 0, 3, 0), 0, 0)); add(selectedDateLabel, new GridBagConstraints(2, 0, 1, 1, 1.0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 3, 3, 3), 0, 0)); add(nextButton, new GridBagConstraints(3, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets( 0, 0, 3, 0), 0, 0)); add(fastNextButton, new GridBagConstraints(4, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets( 0, 0, 3, 0), 0, 0)); nextButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Date old = calendar.getTime(); calendar.add(Calendar.MONTH, 1); firePropertyChange(PROPERTY_NAME_DATE, old, getDate()); reflectData(); } }); prevButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Date old = calendar.getTime(); calendar.add(Calendar.MONTH, -1); firePropertyChange(PROPERTY_NAME_DATE, old, getDate()); reflectData(); } }); fastNextButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Date old = calendar.getTime(); calendar.add(Calendar.YEAR, 1); firePropertyChange(PROPERTY_NAME_DATE, old, getDate()); reflectData(); } }); fastPrevButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Date old = calendar.getTime(); calendar.add(Calendar.YEAR, -1); firePropertyChange(PROPERTY_NAME_DATE, old, getDate()); reflectData(); } }); this.addPropertyChangeListener(this); focusableComponents.add(prevButton); focusableComponents.add(nextButton); focusableComponents.add(fastNextButton); focusableComponents.add(fastPrevButton); createLocaleAndZoneSensitive(); calendar.setTime(aDate); reflectData(); } private void createLocaleAndZoneSensitive() { if (calendar != null) { Date old = calendar.getTime(); calendar = Calendar.getInstance(zone, locale); calendar.setTime(old); } else calendar = Calendar.getInstance(zone, locale); format = new SimpleDateFormat("MMMMM yyyy", locale); format.setTimeZone(zone); setPreferredLabelSize(); } private void setPreferredLabelSize() { Calendar c = Calendar.getInstance(zone, locale); c.setTime(getDate()); JLabel l = new JLabel(); l.setFont(selectedDateLabel.getFont()); int maxWidth = Integer.MIN_VALUE; for (int i = 0; i <= c.getActualMaximum(Calendar.MONTH); i++) { c.set(Calendar.MONTH, i); String text = format.format(c.getTime()); l.setText(text); int w = l.getPreferredSize().width; if (w > maxWidth) maxWidth = w; } Dimension d = l.getPreferredSize(); d.width = maxWidth + 10; selectedDateLabel.setMinimumSize(d); selectedDateLabel.setPreferredSize(d); this.revalidate(); } private void reflectData() { selectedDateLabel.setText(format.format(calendar.getTime())); } public Date getDate() { return calendar.getTime(); } public void setDate(Date date) { Date old = getDate(); calendar.setTime(date); firePropertyChange(PROPERTY_NAME_DATE, old, date); reflectData(); } public Locale getLocale() { return locale; } public void setLocale(Locale locale) { Locale old = this.locale; this.locale = locale; createLocaleAndZoneSensitive(); firePropertyChange(PROPERTY_NAME_LOCALE, old, locale); reflectData(); } public TimeZone getZone() { return zone; } public void setZone(TimeZone zone) { TimeZone old = this.zone; this.zone = zone; createLocaleAndZoneSensitive(); firePropertyChange(PROPERTY_NAME_ZONE, old, locale); reflectData(); } public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("focusable")) { Boolean value = (Boolean) evt.getNewValue(); prevButton.setFocusable(value.booleanValue()); nextButton.setFocusable(value.booleanValue()); fastNextButton.setFocusable(value.booleanValue()); fastPrevButton.setFocusable(value.booleanValue()); } if (evt.getPropertyName().equals("enabled")) { Boolean value = (Boolean) evt.getNewValue(); prevButton.setEnabled(value.booleanValue()); nextButton.setEnabled(value.booleanValue()); fastNextButton.setEnabled(value.booleanValue()); fastPrevButton.setEnabled(value.booleanValue()); } } public Collection getFocusableComponents() { return focusableComponents; } public void addMonth(int m) { int modM = m > 0 ? m : -m; int sign = m > 0 ? 1 : -1; Date old = calendar.getTime(); for (int i = 0; i < modM; i++) { calendar.add(Calendar.MONTH, sign); } firePropertyChange(PROPERTY_NAME_DATE, old, getDate()); reflectData(); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/CalendarGridPanel.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/CalendarGrid0000644000175000017500000004344610634145452032464 0ustar gregoagregoapackage com.michaelbaranov.microba.calendar.ui.basic; import java.awt.Color; import java.awt.Graphics; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Calendar; import java.util.Collection; import java.util.Date; import java.util.HashSet; import java.util.Locale; import java.util.Set; import java.util.TimeZone; import javax.swing.AbstractAction; import javax.swing.BorderFactory; import javax.swing.InputMap; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.KeyStroke; import javax.swing.SwingConstants; import javax.swing.UIManager; import com.michaelbaranov.microba.Microba; import com.michaelbaranov.microba.calendar.CalendarColors; import com.michaelbaranov.microba.calendar.CalendarPane; import com.michaelbaranov.microba.calendar.HolidayPolicy; import com.michaelbaranov.microba.calendar.VetoPolicy; import com.michaelbaranov.microba.common.PolicyEvent; import com.michaelbaranov.microba.common.PolicyListener; class CalendarGridPanel extends JPanel implements FocusListener, PolicyListener, PropertyChangeListener, MouseListener, KeyListener { public static final String PROPERTY_NAME_DATE = "date"; public static final String PROPERTY_NAME_BASE_DATE = "baseDate"; public static final String PROPERTY_NAME_LOCALE = "locale"; public static final String PROPERTY_NAME_ZONE = "zone"; public static final String PROPERTY_NAME_VETO_POLICY = "vetoPolicy"; private static final String PROPERTY_NAME_HOLIDAY_POLICY = "holidayPolicy"; // Not a rela property, ad-hoc approach to notify about clicking selected // date lable public static final String PROPERTY_NAME_NOTIFY_SELECTED_DATE_CLICKED = "##same date clicked##"; private CalendarPane peer; private Date date; private Date baseDate; private Date focusDate; private Locale locale; private TimeZone zone; private VetoPolicy vetoPolicy; private DateLabel labels[] = new DateLabel[42]; private Set focusableComponents = new HashSet(); private boolean explicitDateSetToNullFlag; private HolidayPolicy holidayPolicy; private Color focusColor; private Color restrictedColor; private Color gridBgEn; private Color gridBgDis; private Color gridFgEn; private Color gridFgDis; private Color selBgEn; private Color selBgDis; private Color wkFgEn; private Color wkFgDis; private Color holFgEn; private Color holFgDis; public CalendarGridPanel(CalendarPane peer, Date date, Locale locale, TimeZone zone, VetoPolicy vetoDateModel, HolidayPolicy holidayPolicy) { this.peer = peer; focusColor = Microba.getOverridenColor( CalendarColors.COLOR_CALENDAR_GRID_FOCUS, peer, UIManager .getColor("TabbedPane.focus")); restrictedColor = Microba.getOverridenColor( CalendarColors.COLOR_CALENDAR_GRID_RESTRICTED, peer, Color.RED); gridBgEn = Microba.getOverridenColor( CalendarColors.COLOR_CALENDAR_GRID_BACKGROUND_ENABLED, peer, UIManager.getColor("TextField.background")); gridBgDis = Microba.getOverridenColor( CalendarColors.COLOR_CALENDAR_GRID_BACKGROUND_DISABLED, peer, UIManager.getColor("TextField.background")); gridFgEn = Microba.getOverridenColor( CalendarColors.COLOR_CALENDAR_GRID_FOREGROUND_ENABLED, peer, UIManager.getColor("TextField.foreground")); gridFgDis = Microba.getOverridenColor( CalendarColors.COLOR_CALENDAR_GRID_FOREGROUND_DISABLED, peer, UIManager.getColor("controlText")); selBgEn = Microba .getOverridenColor( CalendarColors.COLOR_CALENDAR_GRID_SELECTION_BACKGROUND_ENABLED, peer, UIManager .getColor("ComboBox.selectionBackground")); selBgDis = Microba .getOverridenColor( CalendarColors.COLOR_CALENDAR_GRID_SELECTION_BACKGROUND_DISABLED, peer, UIManager .getColor("ComboBox.selectionBackground")); wkFgDis = Microba.getOverridenColor( CalendarColors.COLOR_CALENDAR_GRID_WEEKEND_FOREGROUND_DISABLED, peer, gridFgDis); wkFgEn = Microba.getOverridenColor( CalendarColors.COLOR_CALENDAR_GRID_WEEKEND_FOREGROUND_ENABLED, peer, Color.RED); holFgDis = Microba.getOverridenColor( CalendarColors.COLOR_CALENDAR_GRID_HOLIDAY_FOREGROUND_DISABLED, peer, gridFgDis); holFgEn = Microba.getOverridenColor( CalendarColors.COLOR_CALENDAR_GRID_HOLIDAY_FOREGROUND_ENABLED, peer, Color.RED); this.locale = locale; this.zone = zone; this.date = date; this.baseDate = date == null ? new Date() : date; this.explicitDateSetToNullFlag = date == null ? true : false; this.focusDate = getFocusDateForDate(date); this.vetoPolicy = vetoDateModel; this.holidayPolicy = holidayPolicy; if (this.vetoPolicy != null) this.vetoPolicy.addVetoPolicyListener(this); if (this.holidayPolicy != null) this.holidayPolicy.addVetoPolicyListener(this); this.addPropertyChangeListener(this); setLayout(new GridLayout(6, 7, 2, 2)); for (int i = 0; i < 42; i++) { DateLabel l = new DateLabel(i); labels[i] = l; l.setText(String.valueOf(i)); l.addMouseListener(this); add(l); } focusableComponents.add(this); addKeyListener(this); setFocusable(true); // TODO: move the following to key listeners? InputMap input = this.getInputMap(JComponent.WHEN_FOCUSED); input.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "##microba.commit##"); input.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "##microba.commit##"); this.getActionMap().put("##microba.commit##", new AbstractAction() { public void actionPerformed(ActionEvent e) { Calendar c = getCalendar(focusDate); if (vetoPolicy == null || !vetoPolicy.isRestricted(this, c)) { setDate(focusDate); } } }); addFocusListener(this); // addMouseListener(this); setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); reflectData(); } public void focusGained(FocusEvent e) { setBorder(BorderFactory.createLineBorder(focusColor)); reflectFocusedDate(); } public void focusLost(FocusEvent e) { setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); reflectFocusedDate(); } private void setSelectedByIndex(int i) { DateLabel label = labels[i]; if (label.isVisible()) { int day = Integer.parseInt(label.getText()); Calendar c = getCalendar(baseDate); c.set(Calendar.DAY_OF_MONTH, day); setDate(c.getTime()); } } private Calendar getCalendar(Date date) { Calendar c = Calendar.getInstance(zone, locale); c.setTime(date); return c; } private int getSelectedIndex() { if (date == null) return -1; Calendar bc = getCalendar(baseDate); Calendar sc = getCalendar(date); // selectd date visible in base month if (bc.get(Calendar.ERA) == sc.get(Calendar.ERA) && bc.get(Calendar.YEAR) == sc.get(Calendar.YEAR) && bc.get(Calendar.MONTH) == sc.get(Calendar.MONTH)) { bc.set(Calendar.DAY_OF_MONTH, 1); int skipBefore = bc.get(Calendar.DAY_OF_WEEK) - bc.getFirstDayOfWeek(); if (skipBefore < 0) skipBefore = 7 + skipBefore; int selDay = sc.get(Calendar.DAY_OF_MONTH); return skipBefore + selDay - 1; } else return -1; } private void setFocusedByIndex(int i) { DateLabel label = labels[i]; if (label.isVisible()) { int day = Integer.parseInt(label.getText()); Calendar c = getCalendar(baseDate); c.set(Calendar.DAY_OF_MONTH, day); setFocusDate(c.getTime()); } } private int getFocusedIndex() { Calendar bc = getCalendar(baseDate); Calendar fc = getCalendar(focusDate); bc.set(Calendar.DAY_OF_MONTH, 1); int skipBefore = bc.get(Calendar.DAY_OF_WEEK) - bc.getFirstDayOfWeek(); if (skipBefore < 0) skipBefore = 7 + skipBefore; int selDay = fc.get(Calendar.DAY_OF_MONTH); int maxDay = bc.getActualMaximum(Calendar.DAY_OF_MONTH); if (selDay > maxDay) selDay = maxDay; return skipBefore + selDay - 1; } private void reflectData() { setBackground(isEnabled() ? gridBgEn : gridBgDis); reflectBaseDate(); reflectSelectedDate(); reflectFocusedDate(); } private void reflectFocusedDate() { int focusedIndex = getFocusedIndex(); DateLabel l = labels[focusedIndex]; l.setFocused(isFocusOwner()); } private void reflectSelectedDate() { int selIndex = getSelectedIndex(); if (selIndex > -1) { DateLabel l = labels[selIndex]; l.setSelected(true); } } private void reflectBaseDate() { Calendar calendar = getCalendar(baseDate); calendar.set(Calendar.DAY_OF_MONTH, 1); int skipBefore = calendar.get(Calendar.DAY_OF_WEEK) - calendar.getFirstDayOfWeek(); if (skipBefore < 0) skipBefore = 7 + skipBefore; int activeDays = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); int day = 1; calendar.setTime(baseDate); calendar.set(Calendar.DAY_OF_MONTH, 1); for (int i = 0; i < 42; i++) { DateLabel l = labels[i]; l.setBackground(isEnabled() ? selBgEn : selBgDis); l.setSelected(false); l.setFocused(false); l.setEnabled(isEnabled()); if (i < skipBefore) { l.setText(""); l.setVisible(false); } if (i >= skipBefore && i < skipBefore + activeDays) { l.setVisible(true); l.setText(String.valueOf(day)); if (vetoPolicy != null) l.setBanned(vetoPolicy.isRestricted(this.peer, calendar)); else l.setBanned(false); if (holidayPolicy != null) { l.setDate(calendar.getTime()); l .setHolliday(holidayPolicy.isHolliday(this.peer, calendar)); l.setWeekend(holidayPolicy.isWeekend(this.peer, calendar)); } else { l.setHolliday(false); l.setWeekend(false); } day++; calendar.add(Calendar.DAY_OF_MONTH, 1); } if (i >= skipBefore + activeDays) { l.setText(""); l.setVisible(false); } } } public Date getDate() { return date; } public void setDate(Date date) { Date old = this.date; this.date = date; this.explicitDateSetToNullFlag = date == null ? true : false; this.focusDate = getFocusDateForDate(date); if (old != null || date != null) firePropertyChange(PROPERTY_NAME_DATE, old, date); reflectData(); } private Date getFocusDateForDate(Date date) { if (date == null) { Calendar c = getCalendar(baseDate); c.set(Calendar.DAY_OF_MONTH, 1); return c.getTime(); } return date; } public Locale getLocale() { return locale; } public void setLocale(Locale locale) { Locale old = this.locale; this.locale = locale; firePropertyChange(PROPERTY_NAME_LOCALE, old, locale); reflectData(); } public VetoPolicy getVetoPolicy() { return vetoPolicy; } public void setVetoPolicy(VetoPolicy vetoModel) { VetoPolicy old = this.getVetoPolicy(); this.vetoPolicy = vetoModel; firePropertyChange(PROPERTY_NAME_VETO_POLICY, old, vetoModel); reflectData(); } public HolidayPolicy getHolidayPolicy() { return holidayPolicy; } public void setHolidayPolicy(HolidayPolicy holidayPolicy) { HolidayPolicy old = this.getHolidayPolicy(); this.holidayPolicy = holidayPolicy; firePropertyChange(PROPERTY_NAME_HOLIDAY_POLICY, old, holidayPolicy); reflectData(); } public TimeZone getZone() { return zone; } public void setZone(TimeZone zone) { TimeZone old = this.zone; this.zone = zone; firePropertyChange(PROPERTY_NAME_ZONE, old, zone); reflectData(); } public Collection getFocusableComponents() { return focusableComponents; } class DateLabel extends JLabel { private Date date; private int id; private boolean focused; private boolean selected; private boolean weekend; private boolean banned; private boolean holliday; public DateLabel(int id) { super(); this.id = id; setHorizontalAlignment(SwingConstants.CENTER); setFocused(false); setSelected(false); setWeekend(false); setBanned(false); setHolliday(false); } public void setHolliday(boolean b) { holliday = b; update(); repaint(); } public int getId() { return id; } public boolean isFocused() { return focused; } public void setFocused(boolean focused) { this.focused = focused; update(); repaint(); } public boolean isSelected() { return selected; } public void setSelected(boolean selected) { this.selected = selected; update(); repaint(); } private void update() { // background is determined by selected state // foreground by the rest updateBg(); updateFg(); udapteBorder(); // Tooltip: updateTooltip(); } private void updateTooltip() { if (holidayPolicy != null && holliday) { Calendar c = Calendar.getInstance(zone, locale); c.setTime(date); setToolTipText(holidayPolicy.getHollidayName(this, c)); } else setToolTipText(null); } private void udapteBorder() { if (isFocused() && isEnabled()) { setBorder(BorderFactory .createLineBorder(banned ? restrictedColor : focusColor)); } else setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); } private void updateFg() { if (isHolliday()) { setForeground(isEnabled() ? holFgEn : holFgDis); } else { if (isWeekend()) { setForeground(isEnabled() ? wkFgEn : wkFgDis); } else { setForeground(isEnabled() ? gridFgEn : gridFgDis); } } } private void updateBg() { if (isSelected()) { setOpaque(true); setBackground(isEnabled() ? selBgEn : selBgDis); } else setOpaque(false); } public boolean isWeekend() { return weekend; } public void setWeekend(boolean weekend) { this.weekend = weekend; } public boolean isBanned() { return banned; } public void setBanned(boolean banned) { this.banned = banned; update(); repaint(); } public void paint(Graphics g) { if (isBanned()) { g.setColor(restrictedColor); // variant 1: full size cross g.drawLine(2, 2, getWidth() - 4, getHeight() - 4); g.drawLine(2, getHeight() - 4, getWidth() - 4, 2); // variant 2: smaller cross (left upper corner) // g.drawLine(1, 1, 8, 8); // g.drawLine(1, 8, 8, 1); } super.paint(g); } public boolean isHolliday() { return holliday; } public Date getDate() { return date; } public void setDate(Date date) { this.date = date; } } public void policyChanged(PolicyEvent event) { reflectData(); } public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals(PROPERTY_NAME_VETO_POLICY)) { VetoPolicy oldValue = (VetoPolicy) evt.getOldValue(); VetoPolicy newValue = (VetoPolicy) evt.getOldValue(); if (oldValue != null) oldValue.removeVetoPolicyListener(this); if (newValue != null) newValue.addVetoPolicyListener(this); reflectData(); } } public Date getBaseDate() { return baseDate; } public void setBaseDate(Date baseDate) { // TODO: throw away the following 2 lines? // if (baseDate == null) // baseDate = new Date(); Date old = this.baseDate; this.baseDate = baseDate; firePropertyChange(PROPERTY_NAME_BASE_DATE, old, baseDate); // update focus date Calendar bc = getCalendar(baseDate); Calendar fc = getCalendar(focusDate); int focDate = fc.get(Calendar.DAY_OF_MONTH); int maxDay = bc.getActualMaximum(Calendar.DAY_OF_MONTH); if (focDate > maxDay) focDate = maxDay; bc.set(Calendar.DAY_OF_MONTH, focDate); focusDate = bc.getTime(); reflectData(); } private Date getFocusDate() { return focusDate; } private void setFocusDate(Date focusDate) { this.focusDate = focusDate; explicitDateSetToNullFlag = false; reflectData(); } public void mouseClicked(MouseEvent e) { if (!isEnabled()) return; requestFocusInWindow(); DateLabel l = (DateLabel) e.getSource(); if (l.isVisible()) { int id = Integer.parseInt(l.getText()); Calendar c = getCalendar(baseDate); c.set(Calendar.DAY_OF_MONTH, id); if (vetoPolicy == null || !vetoPolicy.isRestricted(this, c)) { boolean selected = l.isSelected(); setDate(c.getTime()); if (selected) firePropertyChange( PROPERTY_NAME_NOTIFY_SELECTED_DATE_CLICKED, null, new Integer(id)); } } } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void keyTyped(KeyEvent e) { } public void keyPressed(KeyEvent e) { if (!isEnabled()) return; int id = getFocusedIndex(); int row = id / 7; int col = id % 7; if (e.getKeyCode() == KeyEvent.VK_DOWN) { row++; if (row < 6) { setFocusedByIndex(row * 7 + col); } } if (e.getKeyCode() == KeyEvent.VK_UP) { row--; if (row >= 0) { setFocusedByIndex(row * 7 + col); } } if (e.getKeyCode() == KeyEvent.VK_LEFT) { col--; if (col >= 0) { setFocusedByIndex(row * 7 + col); } } if (e.getKeyCode() == KeyEvent.VK_RIGHT) { col++; if (col < 7) { setFocusedByIndex(row * 7 + col); } } } public void keyReleased(KeyEvent e) { } public Date getDateToCommit() { Calendar c = getCalendar(focusDate); if (explicitDateSetToNullFlag || (vetoPolicy != null && vetoPolicy.isRestricted(this, c))) return date; return focusDate; } public void setEnabled(boolean enabled) { super.setEnabled(enabled); reflectData(); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/BasicDatePickerUI.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/BasicDatePic0000644000175000017500000003172011050305320032371 0ustar gregoagregoapackage com.michaelbaranov.microba.calendar.ui.basic; import java.awt.BorderLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.beans.PropertyVetoException; import java.text.ParseException; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; import javax.swing.AbstractAction; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.InputMap; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JFormattedTextField; import javax.swing.JPopupMenu; import javax.swing.JTextField; import javax.swing.KeyStroke; import javax.swing.JFormattedTextField.AbstractFormatter; import javax.swing.plaf.ComponentUI; import javax.swing.text.DateFormatter; import javax.swing.text.DefaultFormatterFactory; import com.michaelbaranov.microba.calendar.CalendarPane; import com.michaelbaranov.microba.calendar.CalendarResources; import com.michaelbaranov.microba.calendar.DatePicker; import com.michaelbaranov.microba.calendar.HolidayPolicy; import com.michaelbaranov.microba.calendar.VetoPolicy; import com.michaelbaranov.microba.calendar.resource.Resource; import com.michaelbaranov.microba.calendar.ui.CalendarPaneUI; import com.michaelbaranov.microba.calendar.ui.DatePickerUI; import com.michaelbaranov.microba.common.CommitEvent; import com.michaelbaranov.microba.common.CommitListener; public class BasicDatePickerUI extends DatePickerUI implements PropertyChangeListener { protected static final String POPUP_KEY = "##BasicVetoDatePickerUI.popup##"; protected DatePicker peer; protected CalendarPane calendarPane; protected JButton button; protected JPopupMenu popup; protected JFormattedTextField field; protected ComponentListener componentListener; public static ComponentUI createUI(JComponent c) { return new BasicDatePickerUI(); } public void installUI(JComponent c) { peer = (DatePicker) c; installComponents(); istallListeners(); installKeyboardActions(); } public void uninstallUI(JComponent c) { uninstallKeyboardActions(); uninstallListeners(); uninstallComponents(); peer = null; } protected void installKeyboardActions() { InputMap input = peer .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); input.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.ALT_MASK), POPUP_KEY); input.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0), POPUP_KEY); peer.getActionMap().put(POPUP_KEY, new AbstractAction() { public void actionPerformed(ActionEvent e) { showPopup(true); } }); } protected void uninstallKeyboardActions() { InputMap input = peer .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); input .remove(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.ALT_MASK)); input.remove(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0)); peer.getActionMap().remove(POPUP_KEY); } protected void istallListeners() { peer.addPropertyChangeListener(this); } protected void uninstallListeners() { peer.removePropertyChangeListener(this); } protected void uninstallComponents() { button.removeActionListener(componentListener); field.removePropertyChangeListener(componentListener); calendarPane.removePropertyChangeListener(componentListener); calendarPane.removeCommitListener(componentListener); calendarPane.removeActionListener(componentListener); peer.remove(field); peer.remove(button); popup = null; calendarPane = null; button = null; field = null; } protected void installComponents() { field = new JFormattedTextField(createFormatterFactory()); field.setValue(peer.getDate()); field.setFocusLostBehavior(peer.getFocusLostBehavior()); field.setEditable(peer.isFieldEditable()); field.setToolTipText(peer.getToolTipText()); // button button = new JButton(); button.setFocusable(false); button.setMargin(new Insets(0, 0, 0, 0)); button.setToolTipText(peer.getToolTipText()); setSimpeLook(false); // calendar calendarPane = new CalendarPane(peer.getStyle()); calendarPane.setShowTodayButton(peer.isShowTodayButton()); calendarPane.setFocusLostBehavior(JFormattedTextField.REVERT); calendarPane.setFocusCycleRoot(true); calendarPane.setBorder(BorderFactory.createEmptyBorder(1, 3, 0, 3)); calendarPane.setStripTime(false); calendarPane.setLocale(peer.getLocale()); calendarPane.setZone(peer.getZone()); calendarPane.setFocusable(peer.isDropdownFocusable()); calendarPane.setColorOverrideMap(peer.getColorOverrideMap()); // popup popup = new JPopupMenu(); popup.setLayout(new BorderLayout()); popup.add(calendarPane, BorderLayout.CENTER); popup.setLightWeightPopupEnabled(true); // add peer.setLayout(new BorderLayout()); switch (peer.getPickerStyle()) { case DatePicker.PICKER_STYLE_FIELD_AND_BUTTON: peer.add(field, BorderLayout.CENTER); peer.add(button, BorderLayout.EAST); break; case DatePicker.PICKER_STYLE_BUTTON: peer.add(button, BorderLayout.EAST); break; } peer.revalidate(); peer.repaint(); componentListener = new ComponentListener(); button.addActionListener(componentListener); field.addPropertyChangeListener(componentListener); calendarPane.addPropertyChangeListener(componentListener); calendarPane.addCommitListener(componentListener); calendarPane.addActionListener(componentListener); peerDateChanged(peer.getDate()); } public void setSimpeLook(boolean b) { if (b) { field.setBorder(BorderFactory.createEmptyBorder()); button.setText("..."); button.setIcon(null); } else { field.setBorder(new JTextField().getBorder()); button.setText(""); button.setIcon(new ImageIcon(Resource.class .getResource("picker-16.png"))); } } public void showPopup(boolean visible) { if (visible) { // try to apply date to calendar pane popup, but not cause commit if (peer.isKeepTime()) try { AbstractFormatter formatter = field.getFormatter(); Date value = (Date) formatter .stringToValue(field.getText()); calendarPane .removePropertyChangeListener(componentListener); calendarPane.setDate(value); calendarPane.addPropertyChangeListener(componentListener); } catch (ParseException e) { // ignore } catch (PropertyVetoException e) { // can not happen } popup.show(peer, 0, peer.getHeight()); calendarPane.requestFocus(false); } else { popup.setVisible(false); } } public void propertyChange(PropertyChangeEvent evt) { if (JComponent.TOOL_TIP_TEXT_KEY.equals(evt.getPropertyName())) { field.setToolTipText((String) evt.getNewValue()); button.setToolTipText((String) evt.getNewValue()); } else if (evt.getPropertyName().equals(DatePicker.PROPERTY_NAME_DATE)) { Date newValue = (Date) evt.getNewValue(); peerDateChanged(newValue); } else if (evt.getPropertyName().equals( DatePicker.PROPERTY_NAME_FIELD_EDITABLE)) { field.setEditable(peer.isFieldEditable()); } else if (evt.getPropertyName().equals( DatePicker.PROPERTY_NAME_FOCUS_LOST_BEHAVIOR)) { field.setFocusLostBehavior(peer.getFocusLostBehavior()); } else if (evt.getPropertyName() .equals(DatePicker.PROPERTY_NAME_LOCALE)) { field.setFormatterFactory(createFormatterFactory()); calendarPane.setLocale(peer.getLocale()); } else if (evt.getPropertyName().equals( DatePicker.PROPERTY_NAME_DATE_FORMAT)) { field.setFormatterFactory(createFormatterFactory()); } else if (evt.getPropertyName().equals(DatePicker.PROPERTY_NAME_ZONE)) { field.setFormatterFactory(createFormatterFactory()); calendarPane.setZone((TimeZone) evt.getNewValue()); } else if (evt.getPropertyName().equals( DatePicker.PROPERTY_NAME_SHOW_TODAY_BTN)) { boolean value = ((Boolean) evt.getNewValue()).booleanValue(); calendarPane.setShowTodayButton(value); } else if (evt.getPropertyName().equals( DatePicker.PROPERTY_NAME_SHOW_NONE_BTN)) { boolean value = ((Boolean) evt.getNewValue()).booleanValue(); calendarPane.setShowNoneButton(value); } else if (evt.getPropertyName().equals( DatePicker.PROPERTY_NAME_SHOW_NUMBER_WEEK)) { boolean value = ((Boolean) evt.getNewValue()).booleanValue(); calendarPane.setShowNumberOfWeek(value); } else if (evt.getPropertyName().equals(DatePicker.PROPERTY_NAME_STYLE)) { int value = ((Integer) evt.getNewValue()).intValue(); calendarPane.setStyle(value); } else if (evt.getPropertyName().equals( DatePicker.PROPERTY_NAME_VETO_POLICY)) { calendarPane.setVetoPolicy((VetoPolicy) evt.getNewValue()); } else if (evt.getPropertyName().equals( DatePicker.PROPERTY_NAME_HOLIDAY_POLICY)) { calendarPane.setHolidayPolicy((HolidayPolicy) evt.getNewValue()); } else if (evt.getPropertyName().equals("focusable")) { boolean value = ((Boolean) evt.getNewValue()).booleanValue(); field.setFocusable(value); } else if (evt.getPropertyName().equals( DatePicker.PROPERTY_NAME_RESOURCES)) { CalendarResources resources = (CalendarResources) evt.getNewValue(); calendarPane.setResources(resources); } else if (evt.getPropertyName().equals("enabled"/* * DatePicker.PROPERTY_NAME_ENABLED */)) { boolean value = ((Boolean) evt.getNewValue()).booleanValue(); field.setEnabled(value); button.setEnabled(value); } else if (evt.getPropertyName().equals( DatePicker.PROPERTY_NAME_PICKER_STYLE)) { peer.updateUI(); } else if (evt.getPropertyName().equals( DatePicker.PROPERTY_NAME_DROPDOWN_FOCUSABLE)) { calendarPane.setFocusable(peer.isDropdownFocusable()); } } private void peerDateChanged(Date newValue) { try { calendarPane.removePropertyChangeListener(componentListener); calendarPane.setDate(newValue); calendarPane.addPropertyChangeListener(componentListener); } catch (PropertyVetoException e) { // Ignore. CalendarPane has no VetoModel here. } field.removePropertyChangeListener(componentListener); field.setValue(newValue); field.addPropertyChangeListener(componentListener); } private DefaultFormatterFactory createFormatterFactory() { return new DefaultFormatterFactory(new DateFormatter(peer .getDateFormat())); } protected class ComponentListener implements ActionListener, PropertyChangeListener, CommitListener { public void actionPerformed(ActionEvent e) { if (e.getSource() != calendarPane) showPopup(true); else showPopup(false); } public void propertyChange(PropertyChangeEvent evt) { if (evt.getSource() == calendarPane) { if (CalendarPane.PROPERTY_NAME_DATE.equals(evt .getPropertyName())) { showPopup(false); Date fieldValue = null; try { AbstractFormatter formatter = field.getFormatter(); fieldValue = (Date) formatter.stringToValue(field .getText()); } catch (ParseException e) { fieldValue = (Date) field.getValue(); } if (fieldValue != null || evt.getNewValue() != null) { if (peer.isKeepTime() && fieldValue != null && evt.getNewValue() != null) { Calendar fieldCal = Calendar.getInstance(peer .getZone(), peer.getLocale()); fieldCal.setTime(fieldValue); Calendar valueCal = Calendar.getInstance(peer .getZone(), peer.getLocale()); valueCal.setTime((Date) evt.getNewValue()); // era fieldCal.set(Calendar.ERA, valueCal .get(Calendar.ERA)); // year fieldCal.set(Calendar.YEAR, valueCal .get(Calendar.YEAR)); // month fieldCal.set(Calendar.MONTH, valueCal .get(Calendar.MONTH)); // date fieldCal.set(Calendar.DAY_OF_MONTH, valueCal .get(Calendar.DAY_OF_MONTH)); field.setValue(fieldCal.getTime()); } else field.setValue((Date) evt.getNewValue()); } } } if (evt.getSource() == field) { if ("value".equals(evt.getPropertyName())) { Date value = (Date) field.getValue(); try { peer.setDate(value); } catch (PropertyVetoException e) { field.setValue(peer.getDate()); } } } } public void commit(CommitEvent action) { showPopup(false); if (field.getValue() != null || calendarPane.getDate() != null) field.setValue(calendarPane.getDate()); } public void revert(CommitEvent action) { showPopup(false); } } public void commit() throws PropertyVetoException, ParseException { field.commitEdit(); } public void revert() { peerDateChanged(peer.getDate()); } public void observeMonth(int year, int month) { CalendarPaneUI ui = (CalendarPaneUI) calendarPane.getUI(); ui.observeMonth(year, month); } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/MonthComboBoxModel.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/MonthComboBo0000644000175000017500000000663510412660742032470 0ustar gregoagregoapackage com.michaelbaranov.microba.calendar.ui.basic; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.TimeZone; import javax.swing.AbstractListModel; import javax.swing.ComboBoxModel; class MonthComboBoxModel extends AbstractListModel implements ComboBoxModel { public static final String PROPERTY_NAME_LOCALE = "locale"; public static final String PROPERTY_NAME_DATE = "date"; private PropertyChangeSupport changeSupport = new PropertyChangeSupport( this); private Calendar calendar; private Locale locale; private TimeZone zone; public MonthComboBoxModel(Date date, Locale locale, TimeZone zone) { super(); this.locale = locale; this.zone = zone; createLocaleAndZoneSensitive(); calendar.setTime(date); } private void createLocaleAndZoneSensitive() { if (calendar != null) { Date old = calendar.getTime(); calendar = Calendar.getInstance(zone, locale); calendar.setTime(old); } else calendar = Calendar.getInstance(zone, locale); } public Locale getLocale() { return locale; } public void setLocale(Locale locale) { Locale old = this.locale; this.locale = locale; createLocaleAndZoneSensitive(); changeSupport.firePropertyChange(PROPERTY_NAME_LOCALE, old, locale); fireContentsChanged(this, 0, getSize() - 1); } public Date getDate() { return calendar.getTime(); } public void setDate(Date date) { Date old = getDate(); calendar.setTime(date); changeSupport.firePropertyChange(PROPERTY_NAME_DATE, old, date); fireContentsChanged(this, 0, getSize() - 1); } public void setSelectedItem(Object anItem) { Date aDate = (Date) anItem; setDate(aDate); } public Object getSelectedItem() { return calendar.getTime(); } public int getSize() { return calendar.getActualMaximum(Calendar.MONTH) + 1; } public Object getElementAt(int index) { Calendar c = Calendar.getInstance(locale); c.setTime(calendar.getTime()); c.set(Calendar.MONTH, 0); for (int i = 0; i < index; i++) c.add(Calendar.MONTH, 1); return c.getTime(); } public TimeZone getZone() { return zone; } public void setZone(TimeZone zone) { this.zone = zone; createLocaleAndZoneSensitive(); fireContentsChanged(this, 0, getSize() - 1); } public void addPropertyChangeListener(PropertyChangeListener listener) { changeSupport.addPropertyChangeListener(listener); } public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { changeSupport.addPropertyChangeListener(propertyName, listener); } public PropertyChangeListener[] getPropertyChangeListeners() { return changeSupport.getPropertyChangeListeners(); } public PropertyChangeListener[] getPropertyChangeListeners( String propertyName) { return changeSupport.getPropertyChangeListeners(propertyName); } public boolean hasListeners(String propertyName) { return changeSupport.hasListeners(propertyName); } public void removePropertyChangeListener(PropertyChangeListener listener) { changeSupport.removePropertyChangeListener(listener); } public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { changeSupport.removePropertyChangeListener(propertyName, listener); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/NoGroupingSpinner.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/NoGroupingSp0000644000175000017500000000220010412660742032514 0ustar gregoagregoapackage com.michaelbaranov.microba.calendar.ui.basic; import java.text.NumberFormat; import javax.swing.JComponent; import javax.swing.JFormattedTextField; import javax.swing.JSpinner; import javax.swing.SpinnerModel; import javax.swing.SpinnerNumberModel; import javax.swing.text.DefaultFormatterFactory; import javax.swing.text.NumberFormatter; class NoGroupingSpinner extends JSpinner { public static class NoGroupingNumberEditor extends NumberEditor { public NoGroupingNumberEditor(JSpinner spinner, SpinnerModel model) { super(spinner); JFormattedTextField ftf = (JFormattedTextField) this .getComponent(0); NumberFormat fmt = NumberFormat.getIntegerInstance(); fmt.setGroupingUsed(false); ftf.setFormatterFactory(new DefaultFormatterFactory( new NumberFormatter(fmt))); revalidate(); } } public NoGroupingSpinner(SpinnerModel spinnerModel) { super(spinnerModel); } protected JComponent createEditor(SpinnerModel model) { if (model instanceof SpinnerNumberModel) return new NoGroupingNumberEditor(this, model); return super.createEditor(model); } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/ModernCalendarPanel.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/ModernCalend0000644000175000017500000001162411050603744032465 0ustar gregoagregoapackage com.michaelbaranov.microba.calendar.ui.basic; import java.awt.Component; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Calendar; import java.util.Collection; import java.util.Date; import java.util.HashSet; import java.util.Locale; import java.util.Set; import java.util.TimeZone; import javax.swing.JComboBox; import javax.swing.JPanel; class ModernCalendarPanel extends JPanel implements PropertyChangeListener { public static final String PROPERTY_NAME_DATE = "date"; public static final String PROPERTY_NAME_LOCALE = "locale"; public static final String PROPERTY_NAME_ZONE = "zone"; private Date date; private Locale locale; private TimeZone zone; private YearSpinnerModel yearSpinnerModel; private NoGroupingSpinner yearSpinner; private MonthComboBoxModel monthComboBoxModel; private MonthComboBoxRenderer monthComboBoxRenderer; private JComboBox monthCombo; private Set focusableComponents = new HashSet(); public ModernCalendarPanel(Date aDate, Locale aLocale, TimeZone zone) { this.date = aDate; this.locale = aLocale; this.zone = zone; monthComboBoxModel = new MonthComboBoxModel(aDate, aLocale, zone); monthComboBoxRenderer = new MonthComboBoxRenderer(aLocale, zone); monthCombo = new JComboBox(monthComboBoxModel); monthCombo.setRenderer(monthComboBoxRenderer); yearSpinnerModel = new YearSpinnerModel(aDate, aLocale, zone); yearSpinner = new NoGroupingSpinner(yearSpinnerModel); setLayout(new GridBagLayout()); add(monthCombo, new GridBagConstraints(0, 0, 1, 1, 1.0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 3, 0), 0, 0)); add(yearSpinner, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.VERTICAL, new Insets(0, 3, 3, 0), 0, 0)); focusableComponents.add(yearSpinner); focusableComponents.add(monthCombo); monthComboBoxModel .addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals( MonthComboBoxModel.PROPERTY_NAME_DATE)) { Date newDate = (Date) evt.getNewValue(); setDate(newDate); } } }); yearSpinnerModel .addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals( YearSpinnerModel.PROPERTY_NAME_DATE)) { Date newDate = (Date) evt.getNewValue(); setDate(newDate); } } }); this.addPropertyChangeListener(this); } public void setEnabled(boolean enabled) { super.setEnabled(enabled); monthCombo.setEnabled(enabled); yearSpinner.setEnabled(enabled); } public void setFocusable(boolean focusable) { super.setFocusable(focusable); monthCombo.setFocusable(focusable); yearSpinner.setFocusable(focusable); } public Date getDate() { return date; } public void setDate(Date date) { Date oldDate = this.date; this.date = date; firePropertyChange(PROPERTY_NAME_DATE, oldDate, date); monthComboBoxModel.setDate(date); yearSpinnerModel.setDate(date); } public Locale getLocale() { return locale; } public void setLocale(Locale locale) { Locale old = this.locale; this.locale = locale; monthComboBoxRenderer.setLocale(locale); monthComboBoxModel.setLocale(locale); yearSpinnerModel.setLocale(locale); firePropertyChange(PROPERTY_NAME_LOCALE, old, locale); } public Collection getFocusableComponents() { return focusableComponents; } public TimeZone getZone() { return zone; } public void setZone(TimeZone zone) { TimeZone old = this.zone; this.zone = zone; monthComboBoxRenderer.setZone(zone); monthComboBoxModel.setZone(zone); yearSpinnerModel.setZone(zone); firePropertyChange(PROPERTY_NAME_ZONE, old, zone); } public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("focusable")) { boolean value = ((Boolean) evt.getNewValue()).booleanValue(); yearSpinner.setFocusable(value); Component children[] = yearSpinner.getEditor().getComponents(); for (int i = 0; i < children.length; i++) children[i].setFocusable(value); monthCombo.setFocusable(value); } if (evt.getPropertyName().equals("enabled")) { boolean value = ((Boolean) evt.getNewValue()).booleanValue(); yearSpinner.setEnabled(value); monthCombo.setEnabled(value); } } public void goToMonth(int year, int month) { Date date = getDate(); Calendar calendar = Calendar.getInstance(zone,locale); calendar.setTime(date); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month); setDate(calendar.getTime()); } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/MonthComboBoxRenderer.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/MonthComboBo0000644000175000017500000000250310412660742032456 0ustar gregoagregoapackage com.michaelbaranov.microba.calendar.ui.basic; import java.awt.Component; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.TimeZone; import javax.swing.DefaultListCellRenderer; import javax.swing.JList; class MonthComboBoxRenderer extends DefaultListCellRenderer { // private Locale locale; private TimeZone zone; private SimpleDateFormat dateFormat; public MonthComboBoxRenderer(Locale locale, TimeZone zone) { // this.locale = locale; this.zone = zone; dateFormat = new SimpleDateFormat("MMMM", locale); dateFormat.setTimeZone(zone); } public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); Date date = (Date) value; setText(dateFormat.format(date)); return this; } public void setLocale(Locale locale) { // this.locale = locale; dateFormat = new SimpleDateFormat("MMMM", locale); dateFormat.setTimeZone(zone); } public void setZone(TimeZone zone) { this.zone = zone; dateFormat.setTimeZone(zone); } // public Locale getLocale() { // return locale; // } // // public TimeZone getZone() { // return zone; // } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/AuxPanel.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/ui/basic/AuxPanel.jav0000644000175000017500000001462610502757464032445 0ustar gregoagregoapackage com.michaelbaranov.microba.calendar.ui.basic; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.text.DateFormat; import java.util.Calendar; import java.util.Collection; import java.util.Date; import java.util.HashSet; import java.util.Locale; import java.util.Set; import java.util.TimeZone; import javax.swing.JButton; import javax.swing.JPanel; import com.michaelbaranov.microba.calendar.CalendarResources; import com.michaelbaranov.microba.calendar.VetoPolicy; import com.michaelbaranov.microba.common.PolicyEvent; import com.michaelbaranov.microba.common.PolicyListener; class AuxPanel extends JPanel implements PropertyChangeListener, PolicyListener { public static final String PROPERTY_NAME_LOCALE = "locale"; public static final String PROPERTY_NAME_DATE = "date"; public static final String PROPERTY_NAME_ZONE = "zone"; public static final String PROPERTY_NAME_RESOURCES = "resources"; public static final String PROPERTY_NAME_VETO_MODEL = "vetoModel"; private Locale locale; private TimeZone zone; private JButton todayButton; private JButton noneButton; private DateFormat fullDateFormat; private Date currentDate; private Set focusableComponents = new HashSet(); private VetoPolicy vetoModel; private boolean showTodayBtn; private CalendarResources resources; private boolean showNoneButton; public AuxPanel(Locale locale, TimeZone zone, VetoPolicy vetoModel, boolean showTodayBtn, boolean showNoneButton, CalendarResources resources) { this.locale = locale; this.zone = zone; this.vetoModel = vetoModel; this.showTodayBtn = showTodayBtn; this.showNoneButton = showNoneButton; this.resources = resources; if (vetoModel != null) vetoModel.addVetoPolicyListener(this); setLayout(new GridBagLayout()); todayButton = new JButton(); todayButton.setBorderPainted(false); todayButton.setContentAreaFilled(false); todayButton.setVisible(showTodayBtn); noneButton = new JButton(); noneButton.setBorderPainted(false); noneButton.setContentAreaFilled(false); noneButton.setVisible(showNoneButton); add(todayButton, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); add(noneButton, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); currentDate = new Date(); validateAgainstVeto(); createLocaleAndZoneSensitive(); reflectData(); todayButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { currentDate = new Date(); firePropertyChange(PROPERTY_NAME_DATE, null, currentDate); } }); noneButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { firePropertyChange(PROPERTY_NAME_DATE, null, null); } }); focusableComponents.add(todayButton); this.addPropertyChangeListener(this); // Timer timer = new Timer(true); // timer.schedule(new TimerTask() { // // public void run() { // currentDate = new Date(); // validateAgainstVeto(); // } // }, 0, 60000); } public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("focusable")) { Boolean value = (Boolean) evt.getNewValue(); todayButton.setFocusable(value.booleanValue()); noneButton.setFocusable(value.booleanValue()); } if (evt.getPropertyName().equals("enabled")) { Boolean value = (Boolean) evt.getNewValue(); todayButton.setEnabled(value.booleanValue()); noneButton.setEnabled(value.booleanValue()); } if (evt.getPropertyName().equals(PROPERTY_NAME_VETO_MODEL)) { VetoPolicy oldValue = (VetoPolicy) evt.getOldValue(); VetoPolicy newValue = (VetoPolicy) evt.getOldValue(); if (oldValue != null) oldValue.removeVetoPolicyListener(this); if (newValue != null) newValue.addVetoPolicyListener(this); validateAgainstVeto(); } } private void createLocaleAndZoneSensitive() { fullDateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, locale); fullDateFormat.setTimeZone(zone); } private void reflectData() { String today = resources.getResource(CalendarResources.KEY_TODAY, locale); String none = resources.getResource(CalendarResources.KEY_NONE, locale); todayButton.setText(today + ": " + fullDateFormat.format(currentDate)); noneButton.setText(none); } public Locale getLocale() { return locale; } public void setLocale(Locale locale) { Locale old = this.locale; this.locale = locale; firePropertyChange(PROPERTY_NAME_LOCALE, old, locale); createLocaleAndZoneSensitive(); reflectData(); } public Collection getFocusableComponents() { return focusableComponents; } public TimeZone getZone() { return zone; } public void setZone(TimeZone zone) { this.zone = zone; createLocaleAndZoneSensitive(); reflectData(); } public Date getDate() { return currentDate; } public VetoPolicy getVetoModel() { return vetoModel; } public void setVetoModel(VetoPolicy vetoModel) { VetoPolicy old = this.vetoModel; this.vetoModel = vetoModel; firePropertyChange(PROPERTY_NAME_VETO_MODEL, old, vetoModel); } public void policyChanged(PolicyEvent event) { validateAgainstVeto(); } private void validateAgainstVeto() { Calendar c = Calendar.getInstance(zone, locale); c.setTime(currentDate); if (vetoModel != null) { todayButton.setEnabled(!vetoModel.isRestricted(this, c)); noneButton.setEnabled(!vetoModel.isRestrictNull(this)); } else { todayButton.setEnabled(this.isEnabled()); noneButton.setEnabled(this.isEnabled()); } } public void setShowTodayBtn(boolean value) { showTodayBtn = value; todayButton.setVisible(showTodayBtn); } public void setResources(CalendarResources resources) { CalendarResources old = this.resources; this.resources = resources; firePropertyChange(PROPERTY_NAME_RESOURCES, old, resources); reflectData(); } public void setShowNoneButton(boolean value) { showNoneButton = value; noneButton.setVisible(showNoneButton); } } libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/resource/0000755000175000017500000000000010634142132030330 5ustar gregoagregoa././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/resource/forward-16.pnglibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/resource/forward-16.p0000644000175000017500000000026310412660742032410 0ustar gregoagregoaPNG  IHDR(-SgAMA7tEXtSoftwareAdobe ImageReadyqe<PLTEgtRNS0J%IDATxb`D 0`0`0`0`0RA`||&IENDB`././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/resource/picker-16.pnglibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/resource/picker-16.pn0000644000175000017500000000071510512116242032371 0ustar gregoagregoaPNG  IHDR(-SPLTEuxvqWxsY:q1ֽc־dѺg̷j{KƳnvM(H>?ACFcdeaa__\]Y'YZVSPMKMJHG H >{KtRNS@fbKGDH pHYs  IDATӍ0aؐĈ{R ^Ϝof@z9j9#&pf=q}.bAB(m!@U.11#$5G'^#CAx CFpAJJSJEU-R B߂IENDB`././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/resource/Resource.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/resource/Resource.jav0000644000175000017500000000012710412660742032627 0ustar gregoagregoapackage com.michaelbaranov.microba.calendar.resource; public class Resource { } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/resource/back-fast-16.pnglibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/resource/back-fast-160000644000175000017500000000030110412660742032332 0ustar gregoagregoaPNG  IHDR(-SgAMA7tEXtSoftwareAdobe ImageReadyqe<PLTEgtRNS0J3IDATxb`D 0P 09 H P׋. L[0A_ pгIENDB`libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/resource/back-16.png0000644000175000017500000000027110412660742032170 0ustar gregoagregoaPNG  IHDR(-SgAMA7tEXtSoftwareAdobe ImageReadyqe<PLTEgtRNS0J+IDATxb`D 0 0 0 0 00Ri- /|VEIENDB`././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/resource/forward-fast-16.pnglibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/resource/forward-fast0000644000175000017500000000027510412660742032664 0ustar gregoagregoaPNG  IHDR(-SgAMA7tEXtSoftwareAdobe ImageReadyqe<PLTEgtRNS0J/IDATxb`D 0 K9 $`!O趠DphB8IENDB`././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/DatePickerCellEditor.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/DatePickerCellEditor.0000644000175000017500000000464210537262730032503 0ustar gregoagregoapackage com.michaelbaranov.microba.calendar; import java.beans.PropertyVetoException; import java.util.Date; import javax.swing.DefaultCellEditor; import javax.swing.JCheckBox; import javax.swing.table.TableCellEditor; import javax.swing.tree.TreeCellEditor; import com.michaelbaranov.microba.calendar.ui.DatePickerUI; /** * This class in a concrete implementation of {@link TableCellEditor} and * {@link TreeCellEditor} interfaces. Uses {@link DatePicker} control as en * editor. Subclass to extend functionality. * *

* Note: you probably will want to set the property of the {@link DatePicker} * {@value DatePicker#PROPERTY_NAME_DROPDOWN_FOCUSABLE} to false * before using it to construct {@link DatePickerCellEditor}. * * @see DefaultCellEditor * * @author Michael Baranov * */ public class DatePickerCellEditor extends DefaultCellEditor { /** * Constructor. *

* Note: you probably will want to set the property of the * {@link DatePicker} {@value DatePicker#PROPERTY_NAME_DROPDOWN_FOCUSABLE} * to false before using it to construct * {@link DatePickerCellEditor}. * * @param datePicker * the editor component */ public DatePickerCellEditor(final DatePicker datePicker) { // trick: supply a dummy JCheckBox super(new JCheckBox()); // get back the dummy JCheckBox JCheckBox checkBox = (JCheckBox) this.editorComponent; // remove listeners installed by super() checkBox.removeActionListener(this.delegate); // replace editor component with own this.editorComponent = datePicker; // set simple look ((DatePickerUI) datePicker.getUI()).setSimpeLook(true); // replace delegate with own this.delegate = new EditorDelegate() { public void setValue(Object value) { try { ((DatePicker) editorComponent).setDate((Date) value); } catch (PropertyVetoException e) { } } public Object getCellEditorValue() { return ((DatePicker) editorComponent).getDate(); } public void cancelCellEditing() { ((DatePicker) editorComponent).commitOrRevert(); super.cancelCellEditing(); } public boolean stopCellEditing() { ((DatePicker) editorComponent).commitOrRevert(); return super.stopCellEditing(); } }; // install listeners datePicker.addActionListener(delegate); // do not set it to 1 setClickCountToStart(2); } }libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/VetoPolicy.java0000644000175000017500000000224710412660742031454 0ustar gregoagregoapackage com.michaelbaranov.microba.calendar; import java.util.Calendar; import com.michaelbaranov.microba.common.Policy; /** * This interface is used by {@link CalendarPane} and {@link DatePicker} to * provide means to restrict dates in a control. * * @author Michael Baranov * */ public interface VetoPolicy extends Policy { /** * This method is used to check if a date is restricted. Restricted dates * can not be selected by users in a control. * * @param source * a control calling this method * @param date * a date to check. Is never null * @return true if given date is restricted * false otherwise */ public boolean isRestricted(Object source, Calendar date); /** * This method is used to check if no-date (null date) is * restricted. Restricted dates can not be selected by users in a control. * * @param source * a control calling this method * @return false to allow no-date, true * otherwise */ public boolean isRestrictNull(Object source); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/CalendarResources.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/CalendarResources.jav0000644000175000017500000000157710412660742032627 0ustar gregoagregoapackage com.michaelbaranov.microba.calendar; import java.util.Locale; /** * An interface is used to provide localized string resources for * {@link CalendarPane} and {@link DatePicker} classes. * * @author Michael Baranov * */ public interface CalendarResources { /** * A key for "today" word */ public static final String KEY_TODAY = "key.today"; /** * A key for "none" word */ public static final String KEY_NONE = "key.none"; /** * This method is used to query tring resources for {@link CalendarPane} and * {@link DatePicker} classes. Should not return null. * * @param key * one of the keys defined by {@link CalendarResources} * @param locale * a {@link Locale} * @return localized string resource for a given key */ public String getResource(String key, Locale locale); } libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/CalendarPane.java0000644000175000017500000005156611050604314031674 0ustar gregoagregoapackage com.michaelbaranov.microba.calendar; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.beans.PropertyVetoException; import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.TimeZone; import javax.swing.JFormattedTextField; import javax.swing.event.EventListenerList; import com.michaelbaranov.microba.calendar.ui.CalendarPaneUI; import com.michaelbaranov.microba.common.CommitEvent; import com.michaelbaranov.microba.common.CommitListener; import com.michaelbaranov.microba.common.MicrobaComponent; /** * A concrete implementation of JComponent. Capable of displaying and selecting * dates, much like a real-world calendar. * * @author Michael Baranov */ public class CalendarPane extends MicrobaComponent implements CalendarColors { /** * The name of a "date" property. */ public static final String PROPERTY_NAME_DATE = "date"; /** * The name of a "locale" property. */ public static final String PROPERTY_NAME_LOCALE = "locale"; /** * The name of a "zone" property. */ public static final String PROPERTY_NAME_ZONE = "zone"; /** * The name of a "style" property. */ public static final String PROPERTY_NAME_STYLE = "style"; /** * The name of a "showTodayButton" property. */ public static final String PROPERTY_NAME_SHOW_TODAY_BTN = "showTodayButton"; /** * The name of a "showNoneButton" property. */ public static final String PROPERTY_NAME_SHOW_NONE_BTN = "showNoneButton"; /** * The name of a "focusLocatBehavior" property. */ public static final String PROPERTY_NAME_FOCUS_LOST_BEHAVIOR = "focusLostBehavior"; /** * The name of a "vetoPolicy" property. */ public static final String PROPERTY_NAME_VETO_POLICY = "vetoPlicy"; /** * The name of a "holidayPolicy" property. */ public static final String PROPERTY_NAME_HOLIDAY_POLICY = "holidayPolicy"; /** * The name of a "resources" property. */ public static final String PROPERTY_NAME_RESOURCES = "resources"; /** * The name of a "resources" property. */ public static final String PROPERTY_NAME_SHOW_NUMBER_WEEK = "showNumberOfWeek"; /** * The name of a "stripTime" property. */ public static final String PROPERTY_NAME_STRIP_TIME = "stripTime"; /** * A constant for the "style" property. */ public static final int STYLE_MODERN = 0x10; /** * A constant for the "style" property. */ public static final int STYLE_CLASSIC = 0x20; private static final String uiClassID = "microba.CalendarPaneUI"; private EventListenerList commitListenerList = new EventListenerList(); private EventListenerList actionListenerList = new EventListenerList(); private Date date; private TimeZone zone; private Locale locale; private VetoPolicy vetoPolicy; private HolidayPolicy holidayPolicy; private CalendarResources resources; private int style; private boolean showTodayButton; private boolean showNoneButton; private int focusLostBehavior; private boolean showNumberOfWeek; private boolean stripTime; public String getUIClassID() { return uiClassID; } /** * Constructor. */ public CalendarPane() { this(null, 0, Locale.getDefault(), TimeZone.getDefault()); } /** * Constructor. */ public CalendarPane(int style) { this(null, style, Locale.getDefault(), TimeZone.getDefault()); } /** * Constructor. */ public CalendarPane(Date initialDate) { this(initialDate, 0, Locale.getDefault(), TimeZone.getDefault()); } /** * Constructor. */ public CalendarPane(Date initialDate, int style) { this(initialDate, style, Locale.getDefault(), TimeZone.getDefault()); } /** * Constructor. */ public CalendarPane(Date initialDate, int style, Locale locale) { this(initialDate, style, locale, TimeZone.getDefault()); } /** * Constructor. */ public CalendarPane(Date initialDate, int style, Locale locale, TimeZone zone) { checkStyle(style); checkLocale(locale); checkTimeZone(zone); this.style = style; this.date = initialDate; this.locale = locale; this.zone = zone; this.focusLostBehavior = JFormattedTextField.COMMIT_OR_REVERT; this.showTodayButton = true; this.showNoneButton = true; this.vetoPolicy = null; this.resources = new DefaultCalendarResources(); this.stripTime = true; // forward date property change to action event addPropertyChangeListener(PROPERTY_NAME_DATE, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { fireActionEvent(); } }); updateUI(); } /** * Returns currently selected date in the control. *

* The returned date is guaranteed to pass the restriction check by the * current {@link VetoPolicy}. Based on the value of {@link #stripTime} * property, the returned date may be automatically stripped. * * @return currently selected date * @see #stripTime * @see #stripTime(Date, TimeZone, Locale) */ public Date getDate() { if (this.stripTime) return stripTime(date, getZone(), getLocale()); else return date; } /** * Sets currently selected date to the control. *

* The given date is checked against the current {@link VetoPolicy}. If the * check is passed, the date is transferred to the control and the control * is updated to display the date. *

* A {@link PropertyChangeEvent} may be fired, an {@link ActionEvent} may be * fired. * * @param date * the date to set * @throws PropertyVetoException * if the date is restricted by the current {@link VetoPolicy}. * @see #getVetoPolicy() * @see #setVetoPolicy(VetoPolicy) * @see #addActionListener(ActionListener) */ public void setDate(Date date) throws PropertyVetoException { if (!checkDate(date)) { PropertyChangeEvent propertyChangeEvent = new PropertyChangeEvent( this, PROPERTY_NAME_DATE, this.date, date); throw new PropertyVetoException( "Value vetoed by current vetoPolicy", propertyChangeEvent); } Date old = this.date; this.date = date; if (old != null || date != null) { firePropertyChange(PROPERTY_NAME_DATE, old, date); } } /** * Returns current locale. * * @return current locale */ public Locale getLocale() { return locale; } /** * Sets current locale. *

* The locale is used to construct internal {@link Calendar} instances and * affects visual representation of the control. * * @param locale * the locale to set */ public void setLocale(Locale locale) { Locale old = getLocale(); this.locale = locale; firePropertyChange(PROPERTY_NAME_LOCALE, old, getLocale()); } /** * Returns current time zone. * * @return current time zone */ public TimeZone getZone() { return zone; } /** * Sets current time zone. *

* The time zone is used to construct internal {@link Calendar} instances * and affects visual representation of the control. The dates returned by * {@link #getDate() } will have all time components set to zero considering * the current locale. * * @param zone * the time zone to set */ public void setZone(TimeZone zone) { TimeZone old = getZone(); this.zone = zone; firePropertyChange(PROPERTY_NAME_ZONE, old, getZone()); } /** * Returns current visual style of the control. * * @return current visual style constant. */ public int getStyle() { return style; } /** * Sets the current visual style of the control. *

* The control is then updated to reflect the new style. * * @param style * the style to set * @see #STYLE_CLASSIC * @see #STYLE_MODERN */ public void setStyle(int style) { style = checkStyle(style); int old = this.style; this.style = style; firePropertyChange(PROPERTY_NAME_STYLE, old, style); } /** * Is today button visible? *

* The today button allows the user to quickly select current date. * * @return true if the today button is visible, * false otherwise */ public boolean isShowTodayButton() { return showTodayButton; } /** * Shows or hides the today-button. *

* The today-button allows the user to quickly select current date. * * @param visible * true to show the today-button false * to hide */ public void setShowTodayButton(boolean visible) { Boolean old = new Boolean(this.showTodayButton); this.showTodayButton = visible; firePropertyChange(PROPERTY_NAME_SHOW_TODAY_BTN, old, new Boolean( visible)); } /** * Is the none-button visible? *

* The none-button allows the user to select empty date (null-date, no * date). * * @return true if the none-button is visible, * false otherwise */ public boolean isShowNoneButton() { return showNoneButton; } /** * Shows or hides the none-button. *

* The none-button allows the user to select empty date (null-date, no * date). * * @param visible * true to show the none-button false * to hide */ public void setShowNoneButton(boolean visible) { Boolean old = new Boolean(this.showNoneButton); this.showNoneButton = visible; firePropertyChange(PROPERTY_NAME_SHOW_NONE_BTN, old, new Boolean( visible)); } /** * Returns the focus lost behavior. Possible values are: * *

* Original meaning preserved. * * @return the focus lost behavior constant * @see JFormattedTextField */ public int getFocusLostBehavior() { return focusLostBehavior; } /** * Sets the focus lost behaviour. Possible values are: * * * Original meaning preserved. * * @param behavior * the focus lost behavior constant * @see JFormattedTextField */ public void setFocusLostBehavior(int behavior) { behavior = checkFocusLostbehavior(behavior); int old = this.focusLostBehavior; this.focusLostBehavior = behavior; firePropertyChange(PROPERTY_NAME_FOCUS_LOST_BEHAVIOR, old, behavior); } /** * Resurns current calendar resources model. *

* The model is used to query localized resources for the control. * * @return current calendar resources model * @see CalendarResources */ public CalendarResources getResources() { return resources; } /** * Sets current calendar resources model. *

* The model is used to query localized resources for the control. * * @param resources * a calendar resources model to set. Should not be * null * @see CalendarResources */ public void setResources(CalendarResources resources) { CalendarResources old = this.resources; this.resources = resources; firePropertyChange(PROPERTY_NAME_RESOURCES, old, resources); } /** * Returns current holliday policy (model). *

* The policy is used to query holliday dates and holliday descriptions. * * @return current holliday policy or null if none set * @see HolidayPolicy */ public HolidayPolicy getHolidayPolicy() { return holidayPolicy; } /** * Sets current holliday policy (model) then updates the control to reflect * the policy set. *

* The policy is used to query holliday dates and holiday descriptions. * * @param holidayPolicy * a holliday policy to set. May be null * @see VetoPolicy */ public void setHolidayPolicy(HolidayPolicy holidayPolicy) { HolidayPolicy old = this.holidayPolicy; this.holidayPolicy = holidayPolicy; firePropertyChange(PROPERTY_NAME_HOLIDAY_POLICY, old, holidayPolicy); } /** * Returns the current veto policy (model). *

* The policy is used to veto dates in the control. * * @return current veto policy or null if none set * @see VetoPolicy */ public VetoPolicy getVetoPolicy() { return vetoPolicy; } /** * Sets the current veto policy (model). *

* The policy is used to veto dates in the control. * * @param vetoModel * a veto policy to set. May be null */ public void setVetoPolicy(VetoPolicy vetoModel) { VetoPolicy old = this.vetoPolicy; this.vetoPolicy = vetoModel; firePropertyChange(PROPERTY_NAME_VETO_POLICY, old, vetoModel); } /** * Is the number of every week visible? * * @return true if the number of every week is visible, * false otherwise */ public boolean isShowNumberOfWeek() { return showNumberOfWeek; } /** * Is time protion of the date automatically striped, based on current * locale and ime zone? * * @return true if {@link #getDate()} returns a stripped date, * false otherwise * @see #setStripTime(boolean) * @see #stripTime(Date, TimeZone, Locale) */ public boolean isStripTime() { return stripTime; } /** * Makes {@link #getDate()} either strip the time portion of the date, or * keep it. * * @param stripTime * true to strip time, false to keep * time */ public void setStripTime(boolean stripTime) { this.stripTime = stripTime; } /** * Shows or hides the the number of every week. *

* The number of week is based on the current locale for the component. * * @param visible * true to show the the number of every week * false to hide */ public void setShowNumberOfWeek(boolean visible) { boolean old = this.showNumberOfWeek; this.showNumberOfWeek = visible; firePropertyChange(PROPERTY_NAME_SHOW_NUMBER_WEEK, old, visible); } /** * Adds an {@link ActionListener} listener. * * @param listener * a listener to add * @see ActionListener */ public void addActionListener(ActionListener listener) { actionListenerList.add(ActionListener.class, listener); } /** * Removes an {@link ActionListener} listener. * * @param listener * a listener to remove * @see ActionListener */ public void removeActionListener(ActionListener listener) { actionListenerList.remove(ActionListener.class, listener); } /** * Adds an {@link CommitListener} listener. * * @param listener * a listener to add * @see CommitListener */ public void addCommitListener(CommitListener listener) { commitListenerList.add(CommitListener.class, listener); } /** * Removes an {@link CommitListener} listener. * * @param listener * a listener to remove * @see CommitListener */ public void removeCommitListener(CommitListener listener) { commitListenerList.remove(CommitListener.class, listener); } /** * Forces the control to commit current user's edit. The opertaion may fail * because the date in the control may be restricted by current veto policy. * If successfull, the current date of the control may change, a * {@link CommitEvent} is fired. * * @return true if successful, false otherwise * @see #revertEdit() * @see #getFocusLostBehavior() * @see #setFocusLostBehavior(int) */ public boolean commitEdit() { try { ((CalendarPaneUI) getUI()).commit(); fireCommitEvent(true); return true; } catch (Exception e) { return false; } } /** * Forces the control to revert current user's edit to reflect current * control's date. The current date of the control may change, a * {@link CommitEvent} is fired. * * @see #revertEdit() * @see #getFocusLostBehavior() * @see #setFocusLostBehavior(int) */ public void revertEdit() { ((CalendarPaneUI) getUI()).revert(); fireCommitEvent(false); } /** * Forces the control to commit or revert user's edit depending on the * current focus lost behavior as if the focus would be lost. * * @see #commitEdit() * @see #revertEdit() * @see #getFocusLostBehavior() * @see #setFocusLostBehavior(int) */ public void commitOrRevert() { switch (focusLostBehavior) { case JFormattedTextField.REVERT: revertEdit(); break; case JFormattedTextField.COMMIT: commitEdit(); break; case JFormattedTextField.COMMIT_OR_REVERT: if (!commitEdit()) revertEdit(); break; case JFormattedTextField.PERSIST: // do nothing break; } } /** * Fires a {@link CommitEvent} to all registered listeners. * * @param commit * true to indicate commit, false to * indicate revert * @see CommitEvent * @see CommitListener */ public void fireCommitEvent(boolean commit) { Object[] listeners = commitListenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) if (listeners[i] == CommitListener.class) ((CommitListener) listeners[i + 1]).commit(new CommitEvent( this, commit)); } /** * Fires a {@link ActionEvent} to all registered listeners. * * @see ActionEvent * @see ActionListener */ public void fireActionEvent() { Object[] listeners = actionListenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) if (listeners[i] == ActionListener.class) ((ActionListener) listeners[i + 1]) .actionPerformed(new ActionEvent(this, 0, "value")); } private void checkTimeZone(TimeZone zone) { if (zone == null) throw new IllegalArgumentException("'zone' can not be null."); } private void checkLocale(Locale locale) { if (locale == null) throw new IllegalArgumentException("'locale' can not be null."); } private int checkFocusLostbehavior(int behavior) { if (behavior != JFormattedTextField.COMMIT && behavior != JFormattedTextField.COMMIT_OR_REVERT && behavior != JFormattedTextField.REVERT && behavior != JFormattedTextField.PERSIST) throw new IllegalArgumentException( PROPERTY_NAME_FOCUS_LOST_BEHAVIOR + ": unrecognized behavior"); return behavior; } private boolean checkDate(Date date) { if (vetoPolicy != null) { if (date == null) return !vetoPolicy.isRestrictNull(this); return !vetoPolicy.isRestricted(this, makeCurrentCalendar(date)); } else return true; } private int checkStyle(int style) { if (style == 0) style = STYLE_CLASSIC; if (style != STYLE_CLASSIC && style != STYLE_MODERN) throw new IllegalArgumentException(PROPERTY_NAME_STYLE + ": unrecognized style"); return style; } private Calendar makeCurrentCalendar(Date date) { Calendar c = Calendar.getInstance(zone, locale); c.setTime(date); return c; } /** * Returns same date as given, but time portion (hours, minutes, seconds, * fraction of second) set to zero, based on given locale and time zone. * Utility method. *

* Examle:
* Fri Sep 29 15:57:23 EEST 2006 -> Fri Sep 29 00:00:00 EEST 2006 * * @param date * date to strip time from * @param zone * time zone to get zero fields in * @param locale * locale to base the calendar on * @return stripped date */ public static Date stripTime(Date date, TimeZone zone, Locale locale) { if (date == null) return null; Calendar tmpCalendar = Calendar.getInstance(zone, locale); tmpCalendar.setTime(date); tmpCalendar.set(Calendar.HOUR_OF_DAY, tmpCalendar .getMinimum(Calendar.HOUR_OF_DAY)); tmpCalendar.set(Calendar.MINUTE, tmpCalendar .getMinimum(Calendar.MINUTE)); tmpCalendar.set(Calendar.SECOND, tmpCalendar .getMinimum(Calendar.SECOND)); tmpCalendar.set(Calendar.MILLISECOND, tmpCalendar .getMinimum(Calendar.MILLISECOND)); return tmpCalendar.getTime(); } /** * Makes the widget display given month within given year without actually * changing selected date. * * @param year * year to show * @param month * month within the year to show */ public void observeMonth(int year, int month) { ((CalendarPaneUI) getUI()).observeMonth(year, month); } } libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/HolidayPolicy.java0000644000175000017500000000330010412660742032117 0ustar gregoagregoapackage com.michaelbaranov.microba.calendar; import java.util.Calendar; import com.michaelbaranov.microba.common.Policy; /** * This interface is used by {@link CalendarPane} and {@link DatePicker} to * provide means to define hollidays and optionally provide descriptions to * them. * * @author Michael Baranov * */ public interface HolidayPolicy extends Policy { /** * This method is used to check if a date is a holliday. Holliday dates are * displayed by contols in a special way. * * @param source * a control calling this method * @param date * a date to check * @return true if given date is a holliday * false otherwise */ public boolean isHolliday(Object source, Calendar date); /** * This method is used to check if a date is a weekend date. Implementation * should only check day of week component of the date. * * @param source * a control calling this method * @param date * a date to check * @return true if given date is weekend date * false otherwise */ public boolean isWeekend(Object source, Calendar date); /** * This method is used to query a description for a holliday date. Note, * that implementation may return localized results based on the locale * passed with the date. * * @param source * a control calling this method * @param date * a holliday date to get the description for * @return a localized name (a description) for a holliday */ public String getHollidayName(Object source, Calendar date); } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/DefaultCalendarResources.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/DefaultCalendarResour0000644000175000017500000000222210412660742032646 0ustar gregoagregoapackage com.michaelbaranov.microba.calendar; import java.io.IOException; import java.util.Locale; import java.util.Properties; /** * A very basic implementation of {@link CalendarResources}. Used by default by * {@link CalendarPane} and {@link DatePicker} classes. The resources are loaded * from 'DefaultCalendarResources.properties' file. * * @author Michael Baranov * */ public class DefaultCalendarResources implements CalendarResources { private static final String RESOURCE_FILE = "DefaultCalendarResources.properties"; private static final String DEFAULT_LANGUAGE = "en"; private Properties strings = new Properties(); /** * Constructor. */ public DefaultCalendarResources() { try { strings.load(DefaultCalendarResources.class .getResourceAsStream(RESOURCE_FILE)); } catch (IOException e) { e.printStackTrace(); } } public String getResource(String key, Locale locale) { String language = locale.getLanguage(); String word = (String) strings.get(language + "." + key); if (word == null) word = (String) strings.get(DEFAULT_LANGUAGE + "." + key); return word; } } libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/CalendarColors.java0000644000175000017500000000424210537216170032247 0ustar gregoagregoapackage com.michaelbaranov.microba.calendar; public interface CalendarColors { // *** Header public static final String COLOR_CALENDAR_HEADER_FOREGROUND_ENABLED = "calendar.header.foreground.enabled"; public static final String COLOR_CALENDAR_HEADER_FOREGROUND_DISABLED = "calendar.header.foreground.disabled"; public static final String COLOR_CALENDAR_HEADER_BACKGROUND_ENABLED = "calendar.header.background.enabled"; public static final String COLOR_CALENDAR_HEADER_BACKGROUND_DISABLED = "calendar.header.background.disabled"; public static final String COLOR_CALENDAR_HEADER_FOREGROUND_WEEKEND_ENABLED = "calendar.header.foreground.weekend.enabled"; public static final String COLOR_CALENDAR_HEADER_FOREGROUND_WEEKEND_DISABLED = "calendar.header.foreground.weekend.disabled"; // *** Dates grid public static final String COLOR_CALENDAR_GRID_FOCUS = "calendar.grid.focus"; public static final String COLOR_CALENDAR_GRID_RESTRICTED = "calendar.grid.banned"; // public static final String COLOR_CALENDAR_GRID_BACKGROUND_ENABLED = "calendar.grid.background.enabled"; public static final String COLOR_CALENDAR_GRID_BACKGROUND_DISABLED = "calendar.grid.background.disabled"; public static final String COLOR_CALENDAR_GRID_FOREGROUND_ENABLED = "calendar.grid.foreground.enabled"; public static final String COLOR_CALENDAR_GRID_FOREGROUND_DISABLED = "calendar.grid.foreground.disabled"; // public static final String COLOR_CALENDAR_GRID_SELECTION_BACKGROUND_ENABLED = "calendar.grid.selection.background.enabled"; public static final String COLOR_CALENDAR_GRID_SELECTION_BACKGROUND_DISABLED = "calendar.grid.selection.background.disabled"; public static final String COLOR_CALENDAR_GRID_WEEKEND_FOREGROUND_ENABLED = "calendar.grid.weekend.foreground.enabled"; public static final String COLOR_CALENDAR_GRID_WEEKEND_FOREGROUND_DISABLED = "calendar.grid.weekend.foreground.disabled"; public static final String COLOR_CALENDAR_GRID_HOLIDAY_FOREGROUND_ENABLED = "calendar.grid.holiday.foreground.enabled"; public static final String COLOR_CALENDAR_GRID_HOLIDAY_FOREGROUND_DISABLED = "calendar.grid.holiday.foreground.disabled"; } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/DefaultCalendarResources.propertieslibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/calendar/DefaultCalendarResour0000644000175000017500000000154611050276402032651 0ustar gregoagregoaen.key.none=none en.key.today=today de.key.none=kein de.key.today=heute fr.key.none=non fr.key.today=aujourd'hui pt.key.none=limpar pt.key.today=hoje ru.key.none=\u043D\u0435\u0442 ru.key.today=\u0441\u0435\u0433\u043E\u0434\u043D\u044F it.key.none=nessuno it.key.today=oggi nl.key.none=geen nl.key.today=vandaag es.key.none=ninguna es.key.today=hoy pl.key.none=\u017Caden pl.key.today=dzisiaj by.key.none=\u043Di\u0447\u043E\u0433\u0430 by.key.today=\u0441\u0451\u043D\u043D\u044F da.key.none=ingen da.key.today=i dag ro.key.none=sterge ro.key.today=azi sv.key.none=inget sv.key.today=idag sk.key.none=\u017eiadny sk.key.today=dnes cs.key.none=\u017e\u00e1dn\u00fd cs.key.today=dnes he.key.none=\u05E0\u05E7\u05D4 he.key.today=\u05D4\u05D9\u05D5\u05DD tr.key.none=bug\u00FCn tr.key.today=hi\u00E7biri hu.key.none=ma hu.key.today=semmilibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/marker/0000755000175000017500000000000010634142130026207 5ustar gregoagregoalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/marker/ui/0000755000175000017500000000000010634142130026624 5ustar gregoagregoalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/marker/ui/metal/0000755000175000017500000000000010634142130027726 5ustar gregoagregoa././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/marker/ui/metal/MetalMarkerBarUI.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/marker/ui/metal/MetalMarkerBar0000644000175000017500000000112410527552210032505 0ustar gregoagregoapackage com.michaelbaranov.microba.marker.ui.metal; import java.awt.Graphics; import java.awt.Rectangle; import javax.swing.JComponent; import javax.swing.plaf.ComponentUI; import com.michaelbaranov.microba.marker.ui.basic.BasicMarkerBarUI; public class MetalMarkerBarUI extends BasicMarkerBarUI { public static ComponentUI createUI(JComponent c) { return new MetalMarkerBarUI(); } protected void drawFocusRect(Graphics g, Rectangle viewRect) { g.setColor(getFocusColor()); g.drawRect(viewRect.x, viewRect.y, viewRect.width - 1, viewRect.height - 1); } } libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/marker/ui/MarkerBarUI.java0000644000175000017500000001224110412660742031603 0ustar gregoagregoapackage com.michaelbaranov.microba.marker.ui; import java.awt.Insets; import java.awt.Polygon; import java.awt.Rectangle; import javax.swing.SwingConstants; import javax.swing.plaf.ComponentUI; import com.michaelbaranov.microba.common.BoundedTableModel; import com.michaelbaranov.microba.marker.MarkerBar; public class MarkerBarUI extends ComponentUI { protected int MARKER_BODY_WIDTH = 12; protected int MARKER_BODY_HEIGHT = 12; protected int MARKER_BICK_HEIGHT = 6; protected int baselineLeft; protected int baselineTop; protected int baselineLength; protected Rectangle viewRect = new Rectangle(); protected Polygon[] polys = new Polygon[0]; protected Polygon[] calculateMarkerAreas(MarkerBar bar) { BoundedTableModel model = bar.getDataModel(); int count = model.getRowCount(); if (polys.length < count) { // grow shared polygon array polys = new Polygon[count * 2]; for (int i = 0; i < polys.length; i++) { int xx[] = new int[5]; int yy[] = new int[5]; Polygon p = new Polygon(xx, yy, 5); polys[i] = p; } } for (int i = 0; i < count; i++) { int intValueAt = ((Integer) model.getValueAt(i, bar .getPositionColumn())).intValue(); int logicalOffset = intValueAt - model.getLowerBound(); int baselineOffset = logicalOffsetToBaselineOffset(logicalOffset, model); int xx[] = polys[i].xpoints; int yy[] = polys[i].ypoints; if (bar.getOrientation() == SwingConstants.HORIZONTAL) { int x = baselineLeft + baselineOffset; if (bar.isFliped()) { xx[0] = x; yy[0] = baselineTop; xx[1] = x + MARKER_BODY_WIDTH / 2; yy[1] = baselineTop + MARKER_BICK_HEIGHT; xx[2] = x + MARKER_BODY_WIDTH / 2; yy[2] = baselineTop + MARKER_BICK_HEIGHT + MARKER_BODY_HEIGHT; xx[3] = x - MARKER_BODY_WIDTH / 2; yy[3] = baselineTop + MARKER_BICK_HEIGHT + MARKER_BODY_HEIGHT; xx[4] = x - MARKER_BODY_WIDTH / 2; yy[4] = baselineTop + MARKER_BICK_HEIGHT; } else { xx[0] = x; yy[0] = baselineTop; xx[1] = x + MARKER_BODY_WIDTH / 2; yy[1] = baselineTop - MARKER_BICK_HEIGHT; xx[2] = x + MARKER_BODY_WIDTH / 2; yy[2] = baselineTop - MARKER_BICK_HEIGHT - MARKER_BODY_HEIGHT; xx[3] = x - MARKER_BODY_WIDTH / 2; yy[3] = baselineTop - MARKER_BICK_HEIGHT - MARKER_BODY_HEIGHT; xx[4] = x - MARKER_BODY_WIDTH / 2; yy[4] = baselineTop - MARKER_BICK_HEIGHT; } } else { int y = baselineLeft + baselineOffset; if (bar.isFliped()) { xx[0] = baselineTop; yy[0] = y; yy[1] = y + MARKER_BODY_WIDTH / 2; xx[1] = baselineTop - MARKER_BICK_HEIGHT; yy[2] = y + MARKER_BODY_WIDTH / 2; xx[2] = baselineTop - MARKER_BICK_HEIGHT - MARKER_BODY_HEIGHT; yy[3] = y - MARKER_BODY_WIDTH / 2; xx[3] = baselineTop - MARKER_BICK_HEIGHT - MARKER_BODY_HEIGHT; yy[4] = y - MARKER_BODY_WIDTH / 2; xx[4] = baselineTop - MARKER_BICK_HEIGHT; } else { xx[0] = baselineTop; yy[0] = y; yy[1] = y + MARKER_BODY_WIDTH / 2; xx[1] = baselineTop + MARKER_BICK_HEIGHT; yy[2] = y + MARKER_BODY_WIDTH / 2; xx[2] = baselineTop + MARKER_BICK_HEIGHT + MARKER_BODY_HEIGHT; yy[3] = y - MARKER_BODY_WIDTH / 2; xx[3] = baselineTop + MARKER_BICK_HEIGHT + MARKER_BODY_HEIGHT; yy[4] = y - MARKER_BODY_WIDTH / 2; xx[4] = baselineTop + MARKER_BICK_HEIGHT; } } polys[i].invalidate(); } return polys; } protected int logicalOffsetToBaselineOffset(int logicalOffset, BoundedTableModel model) { int positionRange = model.getUpperBound() - model.getLowerBound(); return logicalOffset * baselineLength / positionRange; } protected int baselineOffsetToLogicalOffset(int baselineOffset, BoundedTableModel model) { int positionRange = model.getUpperBound() - model.getLowerBound(); return baselineOffset * positionRange / baselineLength; } protected int componentOffsetToLogicalOffset(int componentOffsetLeft, BoundedTableModel dataModel) { return baselineOffsetToLogicalOffset( componentOffsetLeft - baselineLeft, dataModel); } protected void calculateViewRectAndBaseline(MarkerBar bar) { Insets insets = bar.getInsets(); viewRect.x = insets.left; viewRect.y = insets.top; viewRect.width = bar.getWidth() - (insets.right + viewRect.x); viewRect.height = bar.getHeight() - (insets.bottom + viewRect.y); if (bar.getOrientation() == SwingConstants.HORIZONTAL) { baselineLeft = viewRect.x + MARKER_BODY_WIDTH / 2; baselineLength = viewRect.width - MARKER_BODY_WIDTH - 1; if (bar.isFliped()) { baselineTop = viewRect.y; } else { baselineTop = viewRect.y + viewRect.height - 1; } } else { baselineLeft = viewRect.y + MARKER_BODY_WIDTH / 2; baselineLength = viewRect.height - MARKER_BODY_WIDTH - 1; if (bar.isFliped()) { baselineTop = viewRect.x + viewRect.width - 1; } else { baselineTop = viewRect.x; } } } public int getMarkerSideGap() { return MARKER_BODY_WIDTH / 2; } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/marker/ui/MarkerBarListener.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/marker/ui/MarkerBarListener.ja0000644000175000017500000002022110412660742032521 0ustar gregoagregoapackage com.michaelbaranov.microba.marker.ui; import java.awt.Polygon; import java.awt.event.ActionEvent; import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.AbstractAction; import javax.swing.JComponent; import javax.swing.KeyStroke; import javax.swing.ListSelectionModel; import javax.swing.SwingConstants; import javax.swing.SwingUtilities; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import com.michaelbaranov.microba.common.BoundedTableModel; import com.michaelbaranov.microba.marker.MarkerBar; import com.michaelbaranov.microba.marker.MarkerMutationModel; import com.michaelbaranov.microba.marker.ui.basic.BasicMarkerBarUI; public class MarkerBarListener implements TableModelListener, MouseListener, MouseMotionListener, FocusListener, PropertyChangeListener, ComponentListener, ListSelectionListener { private static final String VK_DELETE_KEY = "##VK_DELETE##"; private static final KeyStroke DELETE_KEYSTROKE = KeyStroke.getKeyStroke( KeyEvent.VK_DELETE, 0); private final BasicMarkerBarUI barUI; private MarkerBar bar; private int holdingIndex = -1; private int holdingShift; public MarkerBarListener(BasicMarkerBarUI barUI, MarkerBar markerBar) { this.barUI = barUI; this.bar = markerBar; } public void mouseClicked(MouseEvent e) { } public void mousePressed(MouseEvent e) { if (!bar.isEnabled()) return; this.barUI.calculateViewRectAndBaseline(bar); bar.requestFocusInWindow(); BoundedTableModel dataModel = bar.getDataModel(); ListSelectionModel selectionModel = bar.getSelectionModel(); int dataColumn = bar.getPositionColumn(); if (SwingUtilities.isLeftMouseButton(e) && selectionModel != null && dataModel != null) { handleLMBDown(e, dataModel, selectionModel, dataColumn); } if (SwingUtilities.isRightMouseButton(e) && dataModel != null) { handleRMBDown(e, dataModel); } } private void handleRMBDown(MouseEvent e, BoundedTableModel dataModel) { int logicalOffset; if (bar.getOrientation() == SwingConstants.HORIZONTAL) logicalOffset = this.barUI.componentOffsetToLogicalOffset(e.getX(), dataModel); else logicalOffset = this.barUI.componentOffsetToLogicalOffset(e.getY(), dataModel); int logicalPos = dataModel.getLowerBound() + logicalOffset; if (logicalPos >= dataModel.getLowerBound() && logicalPos <= dataModel.getUpperBound()) { MarkerMutationModel mutationModel = bar.getMutationModel(); if (mutationModel != null) mutationModel.addMarkAtPosition(logicalPos); } } private void handleLMBDown(MouseEvent e, BoundedTableModel dataModel, ListSelectionModel selectionModel, int dataColumn) { int numAreas = dataModel.getRowCount(); Polygon areas[] = this.barUI.calculateMarkerAreas(bar); // try already selected for (int i = 0; i < numAreas; i++) { Polygon p = areas[i]; if (p.contains(e.getPoint()) && selectionModel.isSelectedIndex(i) && dataModel.isCellEditable(i, dataColumn)) { holdingIndex = i; return; } } // try editable for (int i = 0; i < numAreas; i++) { Polygon p = areas[i]; if (p.contains(e.getPoint()) && dataModel.isCellEditable(i, dataColumn)) { selectionModel.setSelectionInterval(i, i); holdingIndex = i; if (bar.getOrientation() == SwingConstants.HORIZONTAL) holdingShift = e.getX() - p.xpoints[0]; else holdingShift = e.getY() - p.ypoints[0]; return; } } // try other for (int i = 0; i < numAreas; i++) { Polygon p = areas[i]; if (p.contains(e.getPoint())) { selectionModel.setSelectionInterval(i, i); holdingIndex = -1; return; } } selectionModel.clearSelection(); } public void mouseReleased(MouseEvent e) { holdingIndex = -1; } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mouseDragged(MouseEvent e) { if (!bar.isEnabled()) return; BoundedTableModel dataModel = bar.getDataModel(); if (holdingIndex >= 0 && dataModel != null) { int componentOffset; if (bar.getOrientation() == SwingConstants.HORIZONTAL) componentOffset = e.getX() - holdingShift; else componentOffset = e.getY() - holdingShift; int logicalOffset = this.barUI.componentOffsetToLogicalOffset( componentOffset, dataModel); int logicalPos = dataModel.getLowerBound() + logicalOffset; if (logicalPos < dataModel.getLowerBound()) logicalPos = dataModel.getLowerBound(); if (logicalPos > dataModel.getUpperBound()) logicalPos = dataModel.getUpperBound(); dataModel.setValueAt(new Integer(logicalPos), holdingIndex, bar .getPositionColumn()); } } public void mouseMoved(MouseEvent e) { } public void focusGained(FocusEvent e) { bar.repaint(); } public void focusLost(FocusEvent e) { bar.repaint(); } public void propertyChange(PropertyChangeEvent evt) { if (evt.getSource() instanceof MarkerBar) { if (MarkerBar.PROPERTY_DATA_MODEL.equals(evt.getPropertyName())) { BoundedTableModel oldModel = (BoundedTableModel) evt .getOldValue(); BoundedTableModel newModel = (BoundedTableModel) evt .getNewValue(); if (oldModel != null) oldModel.removeTableModelListener(this); if (newModel != null) newModel.addTableModelListener(this); holdingIndex = -1; bar.revalidate(); } if (MarkerBar.PROPERTY_SELECTION_MODEL.equals(evt .getPropertyName())) { ListSelectionModel oldModel = (ListSelectionModel) evt .getOldValue(); ListSelectionModel newModel = (ListSelectionModel) evt .getNewValue(); if (oldModel != null) oldModel.removeListSelectionListener(this); if (newModel != null) newModel.addListSelectionListener(this); holdingIndex = -1; bar.repaint(); } if (MarkerBar.PROPERTY_MUTATION_MODEL .equals(evt.getPropertyName())) { // do not care } if (MarkerBar.PROPERTY_ORIENTATION.equals(evt.getPropertyName())) { holdingIndex = -1; bar.revalidate(); } if (MarkerBar.PROPERTY_POSITION_COLUMN.equals(evt .getPropertyName())) { holdingIndex = -1; bar.repaint(); } if ("enabled".equals(evt.getPropertyName())) { holdingIndex = -1; bar.repaint(); } } if (evt.getSource() instanceof BoundedTableModel) { bar.revalidate(); } } public void installKeyboardActions(JComponent c) { c.getInputMap().put(DELETE_KEYSTROKE, VK_DELETE_KEY); c.getActionMap().put(VK_DELETE_KEY, new AbstractAction() { public void actionPerformed(ActionEvent e) { BoundedTableModel dataModel = bar.getDataModel(); ListSelectionModel selectionModel = bar.getSelectionModel(); MarkerMutationModel mutationModel = bar.getMutationModel(); if (selectionModel != null && dataModel != null && mutationModel != null && !selectionModel.isSelectionEmpty()) { int selected = selectionModel.getLeadSelectionIndex(); if (dataModel.isCellEditable(selected, bar .getPositionColumn())) { mutationModel.removeMarkerAtIndex(selected); } } } }); } public void uninstallKeyboardActions(JComponent c) { c.getActionMap().remove(VK_DELETE_KEY); c.getInputMap().remove(DELETE_KEYSTROKE); } public void componentResized(ComponentEvent e) { } public void componentMoved(ComponentEvent e) { } public void componentShown(ComponentEvent e) { } public void componentHidden(ComponentEvent e) { } public void tableChanged(TableModelEvent e) { bar.repaint(); } public void valueChanged(ListSelectionEvent e) { bar.repaint(); } }libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/marker/ui/basic/0000755000175000017500000000000010634142130027705 5ustar gregoagregoa././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/marker/ui/basic/BasicMarkerBarUI.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/marker/ui/basic/BasicMarkerBar0000644000175000017500000001761510527552246032470 0ustar gregoagregoapackage com.michaelbaranov.microba.marker.ui.basic; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Insets; import java.awt.Polygon; import java.awt.Rectangle; import java.awt.event.MouseMotionListener; import javax.swing.JComponent; import javax.swing.ListSelectionModel; import javax.swing.LookAndFeel; import javax.swing.SwingConstants; import javax.swing.UIManager; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicGraphicsUtils; import com.michaelbaranov.microba.common.BoundedTableModel; import com.michaelbaranov.microba.marker.MarkerBar; import com.michaelbaranov.microba.marker.ui.MarkerBarListener; import com.michaelbaranov.microba.marker.ui.MarkerBarUI; public class BasicMarkerBarUI extends MarkerBarUI { private Color selectionColor; private Color shadowColor; private Color focusColor; private Color disabledColor; private Color normalColor; private Color textColor; public static ComponentUI createUI(JComponent c) { return new BasicMarkerBarUI(); } public void installUI(JComponent component) { installListeners((MarkerBar) component); installKeyboardActions((MarkerBar) component); installDefaults((MarkerBar) component); } public void uninstallUI(JComponent component) { uninstallListeners((MarkerBar) component); uninstallKeyboardActions((MarkerBar) component); } protected void installDefaults(MarkerBar bar) { LookAndFeel.installBorder(bar, "Slider.border"); LookAndFeel.installColors(bar, "Slider.background", "Slider.foreground"); // selectedmark selectionColor = UIManager.getColor("ComboBox.selectionBackground"); // fixed mark disabledColor = UIManager.getColor("ComboBox.disabledBackground"); normalColor = UIManager.getColor("ComboBox.background"); // focus rect focusColor = UIManager.getColor("Slider.focus"); // text & outline color textColor = UIManager.getColor("textText"); } protected void installKeyboardActions(MarkerBar bar) { MarkerBarListener listener = lookupListsner(bar); if (listener != null) listener.installKeyboardActions(bar); } protected void uninstallKeyboardActions(MarkerBar bar) { MarkerBarListener listener = lookupListsner(bar); if (listener != null) listener.uninstallKeyboardActions(bar); } protected void installListeners(MarkerBar markerBar) { MarkerBarListener listener = createListener(markerBar); if (markerBar.getDataModel() != null) markerBar.getDataModel().addTableModelListener(listener); if (markerBar.getSelectionModel() != null) markerBar.getSelectionModel().addListSelectionListener(listener); markerBar.addMouseListener(listener); markerBar.addMouseMotionListener(listener); markerBar.addFocusListener(listener); markerBar.addPropertyChangeListener(listener); markerBar.addComponentListener(listener); } protected void uninstallListeners(MarkerBar markerBar) { MarkerBarListener listener = lookupListsner(markerBar); if (listener != null) { if (markerBar.getDataModel() != null) markerBar.getDataModel().removeTableModelListener(listener); if (markerBar.getSelectionModel() != null) markerBar.getSelectionModel().removeListSelectionListener(listener); markerBar.removeMouseListener(listener); markerBar.removeMouseMotionListener(listener); markerBar.removeFocusListener(listener); markerBar.removePropertyChangeListener(listener); markerBar.addComponentListener(listener); } } protected MarkerBarListener lookupListsner(MarkerBar markerBar) { MouseMotionListener[] listeners = markerBar.getMouseMotionListeners(); if (listeners != null) { for (int counter = 0; counter < listeners.length; counter++) { if (listeners[counter] instanceof MarkerBarListener) { return (MarkerBarListener) listeners[counter]; } } } return null; } protected MarkerBarListener createListener(MarkerBar markerBar) { return new MarkerBarListener(this, markerBar); } public void paint(Graphics g, JComponent c) { MarkerBar bar = (MarkerBar) c; calculateViewRectAndBaseline(bar); if (bar.isFocusOwner()) drawFocusRect(g, viewRect); BoundedTableModel dataModel = bar.getDataModel(); if (dataModel == null) return; int numAreas = dataModel.getRowCount(); Polygon areas[] = calculateMarkerAreas(bar); ListSelectionModel selectionModel = bar.getSelectionModel(); for (int i = 0; i < numAreas; i++) { boolean isMovable = dataModel.isCellEditable(i, bar.getPositionColumn()); boolean isLeadSelect = (selectionModel == null || selectionModel .isSelectionEmpty()) ? false : selectionModel.getLeadSelectionIndex() == i; if (!isLeadSelect) drawMarker(g, areas[i], false, (Color) dataModel.getValueAt(i, bar .getColorColumn())); } if (selectionModel != null && !selectionModel.isSelectionEmpty()) { int selectedIndex = selectionModel.getLeadSelectionIndex(); boolean isMovable = dataModel.isCellEditable(selectedIndex, bar .getPositionColumn()); if (selectedIndex < numAreas) { drawMarker(g, areas[selectedIndex], /* bar.isFocusOwner() */ true, (Color) dataModel.getValueAt(selectedIndex, bar.getColorColumn())); } else { throw new IllegalStateException( "Selection model inconsistent with data model: " + "element at " + selectedIndex + " selected, but does not exist."); } } } protected void drawFocusRect(Graphics g, Rectangle viewRect) { g.setColor(getFocusColor()); BasicGraphicsUtils.drawDashedRect(g, viewRect.x, viewRect.y, viewRect.width, viewRect.height); } protected void drawMarker(Graphics g, Polygon p, boolean isSelected, Color color) { Color innerColor = color != null ? color : getNormalColor(); // Color selColor = getSelectionColor(); Color selColor = isSelected ? getTextColor() : innerColor; // body g.setColor(innerColor); g.fillPolygon(p); // bick if (isSelected) { int xx[] = new int[3]; int yy[] = new int[3]; xx[0] = p.xpoints[0]; xx[1] = p.xpoints[1]; xx[2] = p.xpoints[p.npoints - 1]; yy[0] = p.ypoints[0]; yy[1] = p.ypoints[1]; yy[2] = p.ypoints[p.npoints - 1]; Polygon bickP = new Polygon(xx, yy, 3); g.setColor(selColor); g.fillPolygon(bickP); g.drawPolygon(bickP); } // outline g.setColor(getTextColor()); g.drawPolygon(p); } public Dimension getMinimumSize(JComponent c) { MarkerBar bar = (MarkerBar) c; Insets ins = bar.getInsets(); if (bar.getOrientation() == SwingConstants.HORIZONTAL) return new Dimension(MARKER_BODY_WIDTH + ins.left + ins.right + 1, MARKER_BODY_HEIGHT + ins.top + ins.bottom + 1); else return new Dimension(MARKER_BODY_HEIGHT + ins.top + ins.bottom + 1, MARKER_BODY_WIDTH + ins.left + ins.right + 1); } public Dimension getPreferredSize(JComponent c) { MarkerBar bar = (MarkerBar) c; BoundedTableModel dataModel = bar.getDataModel(); Insets ins = bar.getInsets(); int r; if (dataModel == null) r = 1; else r = dataModel.getUpperBound() - dataModel.getLowerBound(); if (bar.getOrientation() == SwingConstants.HORIZONTAL) return new Dimension((r) * 2 + MARKER_BODY_WIDTH + ins.left + ins.right + 1, MARKER_BODY_HEIGHT + MARKER_BICK_HEIGHT + ins.top + ins.bottom + 1); else return new Dimension(MARKER_BODY_HEIGHT + MARKER_BICK_HEIGHT + ins.top + ins.bottom + 1, (r) * 2 + MARKER_BODY_WIDTH + ins.left + ins.right + 1); } public Color getFocusColor() { return focusColor; } public Color getShadowColor() { return shadowColor; } public Color getNormalColor() { return normalColor; } public Color getSelectionColor() { return selectionColor; } public Color getDisabledColor() { return disabledColor; } public Color getTextColor() { return textColor; } } libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/marker/ui/windows/0000755000175000017500000000000010634142130030316 5ustar gregoagregoa././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/marker/ui/windows/WindowsMarkerBarUI.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/marker/ui/windows/WindowsMarke0000644000175000017500000000311510527552210032660 0ustar gregoagregoapackage com.michaelbaranov.microba.marker.ui.windows; import java.awt.Graphics; import java.awt.Rectangle; import javax.swing.JComponent; import javax.swing.UIManager; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicGraphicsUtils; import com.michaelbaranov.microba.marker.MarkerBar; import com.michaelbaranov.microba.marker.ui.basic.BasicMarkerBarUI; public class WindowsMarkerBarUI extends BasicMarkerBarUI { private int dashedRectGapX; private int dashedRectGapY; private int dashedRectGapWidth; private int dashedRectGapHeight; private boolean defaults_initialized; public static ComponentUI createUI(JComponent c) { return new WindowsMarkerBarUI(); } protected void drawFocusRect(Graphics g, Rectangle viewRect) { g.setColor(getFocusColor()); g.setColor(getFocusColor()); // BasicGraphicsUtils.drawDashedRect(g, dashedRectGapX, dashedRectGapY, // viewRect.width - dashedRectGapWidth, viewRect.height // - dashedRectGapHeight); BasicGraphicsUtils.drawDashedRect(g, viewRect.x, viewRect.y, viewRect.width - 1, viewRect.height - 1); } protected void installDefaults(MarkerBar b) { super.installDefaults(b); // if(!defaults_initialized) { dashedRectGapX = UIManager.getInt("Button.dashedRectGapX"); dashedRectGapY = UIManager.getInt("Button.dashedRectGapY"); dashedRectGapWidth = UIManager.getInt("Button.dashedRectGapWidth"); dashedRectGapHeight = UIManager.getInt("Button.dashedRectGapHeight"); // focusColor = UIManager.getColor(pp + "focus"); defaults_initialized = true; } } libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/marker/ui/motif/0000755000175000017500000000000010634142130027742 5ustar gregoagregoa././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/marker/ui/motif/MotifMarkerBarUI.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/marker/ui/motif/MotifMarkerBar0000644000175000017500000000102010527552210032530 0ustar gregoagregoapackage com.michaelbaranov.microba.marker.ui.motif; import java.awt.Graphics; import java.awt.Rectangle; import javax.swing.JComponent; import javax.swing.plaf.ComponentUI; import com.michaelbaranov.microba.marker.ui.basic.BasicMarkerBarUI; public class MotifMarkerBarUI extends BasicMarkerBarUI { public static ComponentUI createUI(JComponent c) { return new MotifMarkerBarUI(); } protected void drawFocusRect(Graphics g, Rectangle viewRect) { // focus painting is handled by the border } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/marker/DefaultMarkerModel.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/marker/DefaultMarkerModel.java0000644000175000017500000001306310412660742032574 0ustar gregoagregoapackage com.michaelbaranov.microba.marker; import java.util.ArrayList; import java.util.List; import javax.swing.ListSelectionModel; import com.michaelbaranov.microba.common.AbstractBoundedTableModelWithSelection; /** * A basic implementation of BoundedRangeModel, * ListSelectionModel and MutationModel all in * one. Used by default by JMarkerBar as data model, selection * model and mutation model. *

* * * @author Michael Baranov * @see com.michaelbaranov.microba.marker.MarkerBar */ public class DefaultMarkerModel extends AbstractBoundedTableModelWithSelection implements MarkerMutationModel { private List data = new ArrayList(32); private int lowerBound = 0; private int upperBound = 100; /** * Constructs a DefaultMarkerModel. * */ public DefaultMarkerModel() { super(); setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } /** * Returns the count of markers. Actually returns the cound of rows in the * TableModel. * * @return current marker count. */ public int getRowCount() { return data.size(); } /** * Returns the numbar of columns in the TableModel.This * implementation always returns 1. * * @return always 1. */ public int getColumnCount() { return 1; } /** * Returns the position of a marker, specified by index. * * @param rowIndex * marker index. * @param columnIndex * should be 0. * * @return an Integer position of the marker. * @see #setValueAt(Object, int, int) */ public Object getValueAt(int rowIndex, int columnIndex) { checkIndexes(rowIndex, columnIndex); return data.get(rowIndex); } /** * Assigns a new position to a marker, specified by index (moves the * marker). *

* This implementation does not check if the specified marker position lies * beyond current upper and lower bounds. * * @param aValue * an Integer new position. * @param rowIndex * marker index. * @param columnIndex * should be 0. * @see #getValueAt(int, int) */ public void setValueAt(Object aValue, int rowIndex, int columnIndex) { checkIndexes(rowIndex, columnIndex); Integer newValue = (Integer) aValue; Integer oldValue = (Integer) getValueAt(rowIndex, columnIndex); if (!newValue.equals(oldValue)) { data.remove(rowIndex); data.add(rowIndex, newValue); fireTableCellUpdated(rowIndex, columnIndex); } } /** * This implementation returns Integer.class for * columnIndex=0. * * @param columnIndex * should be 0. * * @return column data class. */ public Class getColumnClass(int columnIndex) { return Integer.class; } /** * This implementation returns "Position" for columnIndex=0. * * @param columnIndex * should be 0. * @return column name. */ public String getColumnName(int columnIndex) { return "Position"; } /** * This implementation always returns true, indicating that * all markers are movable. Override to change behaviour. * * @return always true. */ public boolean isCellEditable(int rowIndex, int columnIndex) { return true; } /** * Removes a marker, specified by index. Actually removes a row from the * TableModel. * * @param index * marker index. * @see #addMarkAtPosition(int) */ public void removeMarkerAtIndex(int index) { if (isSelectedIndex(index)) { removeSelectionInterval(index, index); } data.remove(index); fireTableRowsDeleted(index, index); } /** * Adds a marker with specified position. Actually appends a row to * TableModel with specified position value. Returns the * index of the added mark. *

* This implementation does not check if the specified marker position lies * beyond current upper and lower bounds. * * @return index of added mark. * @see #removeMarkerAtIndex(int) */ public int addMarkAtPosition(int position) { data.add(new Integer(position)); int row = data.size() - 1; fireTableRowsInserted(row, row); setSelectionInterval(row, row); return row; } /** * @inheritDoc * @see #setLowerBound(int) */ public int getLowerBound() { return lowerBound; } /** * @inheritDoc * @see #setUpperBound(int) */ public int getUpperBound() { return upperBound; } /** * Sets current lower bound. * * @param lowerBound * new lower bound value. * @see #setLowerBound(int) */ public void setLowerBound(int lowerBound) { if (lowerBound >= upperBound) throw new IllegalArgumentException("lowerBound >= upperBound"); int old = this.lowerBound; this.lowerBound = lowerBound; firePropertyChange(PROPERTY_LOWER_BOUND, old, lowerBound); } /** * Sets current upper bound. * * @param upperBound * new upper bound value. * @see #getUpperBound() */ public void setUpperBound(int upperBound) { int old = this.upperBound; this.upperBound = upperBound; firePropertyChange(PROPERTY_UPPER_BOUND, old, upperBound); } private void checkIndexes(int rowIndex, int columnIndex) { if (columnIndex != 0) throw new IndexOutOfBoundsException("columnIndex: " + columnIndex); if (rowIndex < 0 || rowIndex >= data.size()) throw new IndexOutOfBoundsException("rowIndex: " + rowIndex); } } libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/marker/MarkerBar.java0000644000175000017500000002537310527260170030740 0ustar gregoagregoapackage com.michaelbaranov.microba.marker; import javax.swing.DefaultListSelectionModel; import javax.swing.ListSelectionModel; import javax.swing.SwingConstants; import com.michaelbaranov.microba.common.BoundedTableModel; import com.michaelbaranov.microba.common.MicrobaComponent; import com.michaelbaranov.microba.marker.ui.MarkerBarUI; /** * A bar with multiple draggable position marks. *

* Features: *

* * Implementation details: * *

* * This implementation queries marker positions from a single table column of * the data model. The index defaults to 0, but you can specify it with * {@link #setPositionColumn(int)}. * A marker is considered to be unmovable, if corresponding table cell of the * data model is reported to be uneditable. *

* * This implementation determines the only currently selected marker with * {@link ListSelectionModel#getLeadSelectionIndex()} * of the selection model, so current selection model's selection mode has no * effect. * * @author Michael Baranov * */ public class MarkerBar extends MicrobaComponent { /** * The name of a "dataModel" property. */ public static final String PROPERTY_DATA_MODEL = "dataModel"; /** * The name of a "selectionModel" property. */ public static final String PROPERTY_SELECTION_MODEL = "selectionModel"; /** * The name of a "mutationModel" property. */ public static final String PROPERTY_MUTATION_MODEL = "mutationModel"; /** * The name of a "orientation" property. */ public static final String PROPERTY_ORIENTATION = "orientation"; /** * The name of a "positionColumn" property. */ public static final String PROPERTY_POSITION_COLUMN = "positionColumn"; /** * The name of a "colorColumn" property. */ public static final String PROPERTY_COLOR_COLUMN = "colorColumn"; /** * The name of a "fliped" property. */ public static final String PROPERTY_FLIP = "fliped"; private static final String uiClassID = "microba.MarkerBarUI"; private BoundedTableModel dataModel = null; private ListSelectionModel selectionModel = null; private MarkerMutationModel mutationModel = null; private int positionColumn = 0; private int colorColumn = -1; private int orientation = SwingConstants.HORIZONTAL; private boolean fliped = false; /** * Constructs a MarkerBar with all models set to a single * DefaultMarkerModel. * * @see DefaultMarkerModel */ public MarkerBar() { super(); DefaultMarkerModel markerModel = new DefaultMarkerModel(); dataModel = markerModel; selectionModel = markerModel; mutationModel = markerModel; setFocusable(true); updateUI(); } /** * Constructs a MarkerBar with given orientation. All models * set to a single DefaultMarkerModel. * * @param orientation * initial orientation. Possible values: * SwingConstants.HORIZONTAL or * SwingConstants.VERTICAL * @see DefaultMarkerModel */ public MarkerBar(int orientation) { super(); DefaultMarkerModel markerModel = new DefaultMarkerModel(); dataModel = markerModel; selectionModel = markerModel; mutationModel = markerModel; this.orientation = orientation; setFocusable(true); updateUI(); } /** * Constructs a MarkerBar with given data model, a * DefaultListSelectionModel as selection model and no mutation model. * * @param dataModel * initial data model. May be null * * @see BoundedTableModel */ public MarkerBar(BoundedTableModel dataModel) { super(); this.dataModel = dataModel; selectionModel = new DefaultListSelectionModel(); mutationModel = null; setFocusable(true); updateUI(); } /** * Constructs a MarkerBar with given data model and selection * model. No mutation model. * * @param dataModel * initial data model. May be null; * @param selectionModel initial selection model. * @see BoundedTableModel */ public MarkerBar(BoundedTableModel dataModel, ListSelectionModel selectionModel) { super(); this.dataModel = dataModel; this.selectionModel = selectionModel; mutationModel = null; setFocusable(true); updateUI(); } /** * Look&Feel UI delegate key (classID). This implementation returns: * "MarkerBarUI". */ public String getUIClassID() { return uiClassID; } /** * Returns current data model. * * @return current BoundedTableModel. * @see #setDataModel(BoundedTableModel) * @see BoundedTableModel */ public BoundedTableModel getDataModel() { return dataModel; } /** * Replaces current data model with specified one. This implementation uses * current position column index to query marker positions. * * @param model * new data model. * @see #getDataModel() * @see #getPositionColumn() * @see BoundedTableModel */ public void setDataModel(BoundedTableModel model) { BoundedTableModel oldModel = this.dataModel; this.dataModel = model; firePropertyChange(PROPERTY_DATA_MODEL, oldModel, model); } /** * Returns current component orientation. * * @return current component orientation. * @see #setOrientation(int) */ public int getOrientation() { return orientation; } /** * Re-orientates the component. * * @param orientation * new orientation value. Possible values: * {@link SwingConstants#HORIZONTAL} or * {@link SwingConstants#VERTICAL} * @see #getOrientation() */ public void setOrientation(int orientation) { int oldOrientation = this.orientation; this.orientation = orientation; firePropertyChange(PROPERTY_ORIENTATION, oldOrientation, orientation); } /** * Returns current mutation model. * * @return current MutationModel. * @see #setMutationModel(MarkerMutationModel) * @see MarkerMutationModel */ public MarkerMutationModel getMutationModel() { return mutationModel; } /** * Replaces current mutation model with given one. * * @param mutationModel * new mutation model. May be null. * @see #getMutationModel() * @see MarkerMutationModel */ public void setMutationModel(MarkerMutationModel mutationModel) { MarkerMutationModel oldMutationModel = this.mutationModel; this.mutationModel = mutationModel; firePropertyChange(PROPERTY_MUTATION_MODEL, oldMutationModel, mutationModel); } /** * Returns current selection model. * * @return current ListSelectionModel. * @see #setSelectionModel(ListSelectionModel) */ public ListSelectionModel getSelectionModel() { return selectionModel; } /** * Replaces current selection model with given one. This implementation uses * {@link ListSelectionModel#getLeadSelectionIndex()} to * determine selected marker. * * @param selectionModel * new selection model. May be null. * * @see #getSelectionModel() */ public void setSelectionModel(ListSelectionModel selectionModel) { ListSelectionModel oldSelectionModel = this.selectionModel; this.selectionModel = selectionModel; firePropertyChange(PROPERTY_SELECTION_MODEL, oldSelectionModel, selectionModel); } /** * Returns an index of currently used table column to query marker position. * * @return current position column index. * @see #setPositionColumn(int) */ public int getPositionColumn() { return positionColumn; } /** * Sets the index of the data model table column used to query marker * position. * * @param positionColumn * new position column index. * @see #getPositionColumn() */ public void setPositionColumn(int positionColumn) { int oldDataColumn = this.positionColumn; this.positionColumn = positionColumn; firePropertyChange(PROPERTY_POSITION_COLUMN, oldDataColumn, positionColumn); } /** * Returns an index of currently used table column to query marker color. * Defaults to -1, which means not to query data model for color. * * @return current color column index. * @see #setColorColumn(int) */ public int getColorColumn() { return colorColumn; } /** * Sets the index of the data model table column used to query marker color. * Set to -1 in order not to query data model for color data. * * @param colorColumn * new color column index. * @see #getColorColumn() */ public void setColorColumn(int colorColumn) { int old = this.colorColumn; this.colorColumn = colorColumn; firePropertyChange(PROPERTY_COLOR_COLUMN, old, colorColumn); } /** * Returns a distance in pixeld between the edge of the component (left & * right edge for horizontal orientation, top & bottom edge for vertical) * and a marker beak point in outermost position. The value is actually * queried from current UI delegate. * * @return Gap value. * @see MarkerBarUI */ public int getMarkerSideGap() { return ((MarkerBarUI) getUI()).getMarkerSideGap(); } /** * Returns current flip flag value. *

* The flip flag defines where marker bicks are pointed:
* true: down for horizontal orientation, left for vertical.
* false: up for horizontal orientation, right for vertical. * * @return current flip value. */ public boolean isFliped() { return fliped; } /** * Set flip flag value. *

* The flip flag defines where marker bicks are pointed:
* true: down for horizontal orientation, left for vertical.
* false: up for horizontal orientation, right for vertical. * * @param flip * new flip flag value. */ public void setFliped(boolean flip) { boolean old = this.fliped; this.fliped = flip; firePropertyChange(PROPERTY_FLIP, old, flip); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/marker/MarkerMutationModel.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/marker/MarkerMutationModel.jav0000644000175000017500000000174410412660742032652 0ustar gregoagregoapackage com.michaelbaranov.microba.marker; /** * A callback interface used exclusively by * {@link com.michaelbaranov.microba.marker.MarkerBar} as a * mutation model. *

* The JMarkerBar class notifies an implementor of the * MutationModel about the fact, that the user is requesting a * marker to be removed or added. * * @author Michael Baranov * @see com.michaelbaranov.microba.marker.MarkerBar */ public interface MarkerMutationModel { /** * Called when the user requests a mark to be removed from * JMarkerBar. * * @param index * index of the mark to be removed. */ void removeMarkerAtIndex(int index); /** * Called when the user requests a mark to be inserted into * JMarkerBar. * * @param position * position at which to insert the mark. * @return index of newly added mark. */ int addMarkAtPosition(int position); } libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/gradient/0000755000175000017500000000000010634142132026525 5ustar gregoagregoalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/gradient/ui/0000755000175000017500000000000010634142132027142 5ustar gregoagregoalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/gradient/ui/GradientUI.java0000644000175000017500000000702210412660742032007 0ustar gregoagregoapackage com.michaelbaranov.microba.gradient.ui; import java.awt.Color; import java.awt.Insets; import java.awt.Rectangle; import java.util.Arrays; import java.util.Comparator; import javax.swing.plaf.ComponentUI; import com.michaelbaranov.microba.common.BoundedTableModel; import com.michaelbaranov.microba.gradient.GradientBar; public class GradientUI extends ComponentUI { protected static final int PREF_BAR_HEIGHT = 32; protected static Rectangle viewRect = new Rectangle(); private PreparedColorPoint colorPoints[] = new PreparedColorPoint[0]; private PreparedAlphaPoint alphaPoints[] = new PreparedAlphaPoint[0]; protected void calculateViewRect(GradientBar gradient) { Insets insets = gradient.getInsets(); viewRect.x = insets.left; viewRect.y = insets.top; viewRect.width = gradient.getWidth() - (insets.right + viewRect.x); viewRect.height = gradient.getHeight() - (insets.bottom + viewRect.y); } protected PreparedColorPoint[] prepareColorPoints(BoundedTableModel model, int positionColumn, int colorColumn) { int numPoints = model.getRowCount(); if (numPoints > colorPoints.length) { colorPoints = new PreparedColorPoint[numPoints * 2]; for (int i = 0; i < colorPoints.length; i++) colorPoints[i] = new PreparedColorPoint(); } for (int i = 0; i < numPoints; i++) { PreparedColorPoint p = colorPoints[i]; Color c = (Color) model.getValueAt(i, colorColumn); p.position = ((Number) model.getValueAt(i, positionColumn)) .intValue(); p.r = c.getRed(); p.g = c.getGreen(); p.b = c.getBlue(); } Arrays.sort(colorPoints, 0, numPoints, PreparedColorPoint.comparator); return colorPoints; } protected PreparedAlphaPoint[] prepareAlphaPoints(BoundedTableModel model, int positionColumn, int alphaColumn) { int numPoints = model.getRowCount(); if (numPoints > alphaPoints.length) { alphaPoints = new PreparedAlphaPoint[numPoints * 2]; for (int i = 0; i < alphaPoints.length; i++) alphaPoints[i] = new PreparedAlphaPoint(); } for (int i = 0; i < numPoints; i++) { PreparedAlphaPoint p = alphaPoints[i]; float f = ((Number) model.getValueAt(i, alphaColumn)).floatValue(); p.position = ((Number) model.getValueAt(i, positionColumn)) .intValue(); p.alpha = f; } Arrays.sort(alphaPoints, 0, numPoints, PreparedAlphaPoint.comparator); return alphaPoints; } protected static class PreparedColorPoint { public static final Comparator comparator = new PtComparator(); public int r, g, b; public int position; public PreparedColorPoint() { } private static class PtComparator implements Comparator { public int compare(Object o1, Object o2) { PreparedColorPoint cp1 = (PreparedColorPoint) o1; PreparedColorPoint cp2 = (PreparedColorPoint) o2; if (cp1.position < cp2.position) return -1; if (cp1.position > cp2.position) return 1; return 0; } } } protected static class PreparedAlphaPoint { public static final Comparator comparator = new PtComparator(); public float alpha; public int position; public PreparedAlphaPoint() { } private static class PtComparator implements Comparator { public int compare(Object o1, Object o2) { PreparedColorPoint cp1 = (PreparedColorPoint) o1; PreparedColorPoint cp2 = (PreparedColorPoint) o2; if (cp1.position < cp2.position) return -1; if (cp1.position > cp2.position) return 1; return 0; } } } } libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/gradient/ui/basic/0000755000175000017500000000000010634142132030223 5ustar gregoagregoa././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/gradient/ui/basic/BasicGradientUI.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/gradient/ui/basic/BasicGradien0000644000175000017500000001244310517524646032503 0ustar gregoagregoapackage com.michaelbaranov.microba.gradient.ui.basic; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Insets; import java.beans.PropertyChangeListener; import javax.swing.JComponent; 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.gradient.ui.GradientListener; import com.michaelbaranov.microba.gradient.ui.GradientUI; public class BasicGradientUI extends GradientUI { public static ComponentUI createUI(JComponent c) { return new BasicGradientUI(); } public void installUI(JComponent component) { installListeners((GradientBar) component); } public void uninstallUI(JComponent component) { uninstallListeners((GradientBar) component); } protected void installListeners(GradientBar gradient) { GradientListener listener = createListener(gradient); if (gradient.getDataModel() != null) gradient.getDataModel().addTableModelListener(listener); gradient.addPropertyChangeListener(listener); } protected void uninstallListeners(GradientBar gradient) { GradientListener listener = lookupListsner(gradient); if (listener != null) { if (gradient.getDataModel() != null) gradient.getDataModel().removeTableModelListener(listener); gradient.removePropertyChangeListener(listener); } } protected GradientListener lookupListsner(GradientBar gradient) { PropertyChangeListener[] listeners = gradient .getPropertyChangeListeners(); if (listeners != null) { for (int counter = 0; counter < listeners.length; counter++) { if (listeners[counter] instanceof GradientListener) { return (GradientListener) listeners[counter]; } } } return null; } protected GradientListener createListener(GradientBar gradient) { return new GradientListener(this, gradient); } public void paint(Graphics g, JComponent c) { Graphics2D g2 = (Graphics2D) g; GradientBar gradient = (GradientBar) c; calculateViewRect(gradient); BoundedTableModel colorModel = gradient.getDataModel(); BoundedTableModel alphaModel = gradient.getAlphaModel(); if (colorModel == null) return; // TODO: alpha support int numColorPoints = colorModel.getRowCount(); int numAlphaPoints = alphaModel == null ? 0 : alphaModel.getRowCount(); int colorPositionColumn = gradient.getColorPositionColumn(); int colorColumn = gradient.getColorColumn(); int alphaPositionColumn = gradient.getAlphaPositionColumn(); int alphaColumn = gradient.getAlphaColumn(); switch (numColorPoints) { case 0: // draw checkers? // g.drawString("no data", viewRect.x, viewRect.y + // viewRect.height); break; case 1: g.setColor((Color) colorModel.getValueAt(0, colorColumn)); g.fillRect(viewRect.x, viewRect.y, viewRect.width, viewRect.height); break; default: PreparedColorPoint pts[] = prepareColorPoints(colorModel, colorPositionColumn, colorColumn); // PreparedAlphaPoint apts[] = prepareAlphaPoints(alphaModel, // colorPositionColumn, colorColumn); int range = colorModel.getUpperBound() - colorModel.getLowerBound(); boolean isHorizontal = gradient.getOrientation() == SwingConstants.HORIZONTAL; for (int i = 0; i < numColorPoints - 1; i++) { PreparedColorPoint p0 = pts[i]; PreparedColorPoint p1 = pts[i + 1]; int pos0 = p0.position - colorModel.getLowerBound(); int pos1 = p1.position - colorModel.getLowerBound(); int pixPos0; int pixPos1; if (isHorizontal) { pixPos0 = viewRect.x + viewRect.width * pos0 / range; pixPos1 = viewRect.x + viewRect.width * pos1 / range; } else { pixPos0 = viewRect.y + viewRect.height * pos0 / range; pixPos1 = viewRect.y + viewRect.height * pos1 / range; } int pixDist = pixPos1 - pixPos0; for (int t = pixPos0; t < pixPos1; t++) { Color cc = interpolate(p0, p1, pixDist, t - pixPos0); g2.setColor(cc); if (isHorizontal) g2.drawLine(t, viewRect.y, t, viewRect.y + viewRect.height); else g2.drawLine(viewRect.x, t, viewRect.x + viewRect.width, t); } } break; } } private Color interpolate(PreparedColorPoint p0, PreparedColorPoint p1, int pixDist, int t) { int r = p0.r + (p1.r - p0.r) * t / pixDist; int g = p0.g + (p1.g - p0.g) * t / pixDist; int b = p0.b + (p1.b - p0.b) * t / pixDist; return new Color(r, g, b); } public Dimension getMinimumSize(JComponent c) { return new Dimension(1, 1); } public Dimension getPreferredSize(JComponent c) { GradientBar gradient = (GradientBar) c; BoundedTableModel dataModel = gradient.getDataModel(); Insets ins = gradient.getInsets(); int r; if (dataModel == null) r = 1; else r = dataModel.getUpperBound() - dataModel.getLowerBound(); if (gradient.getOrientation() == SwingConstants.HORIZONTAL) return new Dimension((r) * 2 + ins.left + ins.right + 1, PREF_BAR_HEIGHT + ins.top + ins.bottom + 1); else return new Dimension(PREF_BAR_HEIGHT + ins.top + ins.bottom + 1, (r) * 2 + ins.left + ins.right + 1); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/gradient/ui/GradientListener.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/gradient/ui/GradientListener.j0000644000175000017500000000320510412660742032566 0ustar gregoagregoapackage com.michaelbaranov.microba.gradient.ui; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import com.michaelbaranov.microba.common.BoundedTableModel; import com.michaelbaranov.microba.gradient.GradientBar; import com.michaelbaranov.microba.gradient.ui.basic.BasicGradientUI; public class GradientListener implements TableModelListener, PropertyChangeListener { private final BasicGradientUI gradientUI; private GradientBar gradient; public GradientListener(BasicGradientUI gradientUI, GradientBar gradient) { this.gradientUI = gradientUI; this.gradient = gradient; } public void propertyChange(PropertyChangeEvent evt) { if (GradientBar.PROPERTY_DATA_MODEL.equals(evt.getPropertyName())) { BoundedTableModel oldModel = (BoundedTableModel) evt.getOldValue(); BoundedTableModel newModel = (BoundedTableModel) evt.getNewValue(); if (oldModel != null) oldModel.removeTableModelListener(this); if (newModel != null) newModel.addTableModelListener(this); gradient.revalidate(); } if (GradientBar.PROPERTY_ORIENTATION.equals(evt.getPropertyName())) { gradient.revalidate(); } if (GradientBar.PROPERTY_COLOR_POSITION_COLUMN.equals(evt.getPropertyName())) { gradient.repaint(); } if (GradientBar.PROPERTY_COLOR_COLUMN.equals(evt.getPropertyName())) { gradient.repaint(); } if ("enabled".equals(evt.getPropertyName())) { gradient.repaint(); } } public void tableChanged(TableModelEvent e) { gradient.repaint(); } }././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/gradient/DefaultGradientModel.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/gradient/DefaultGradientModel.0000644000175000017500000000432310412660742032561 0ustar gregoagregoapackage com.michaelbaranov.microba.gradient; import java.awt.Color; import java.util.ArrayList; import java.util.List; import com.michaelbaranov.microba.common.AbstractBoundedTableModel; /** * A very basic implementation of {@link AbstractBoundedTableModel} used by * default by {@link GradientBar}. This implementation has bounds 0 - 100 and * is mutable. * * @author Michael Baranov * */ public class DefaultGradientModel extends AbstractBoundedTableModel { protected static final int POSITION_COLUMN = 0; protected static final int COLOR_COLUMN = 1; protected List positionList = new ArrayList(32); protected List colorList = new ArrayList(32); /** * Constructor. */ public DefaultGradientModel() { super(); positionList.add(new Integer(0)); colorList.add(Color.YELLOW); positionList.add(new Integer(50)); colorList.add(Color.RED); positionList.add(new Integer(100)); colorList.add(Color.GREEN); } public int getLowerBound() { return 0; } public int getUpperBound() { return 100; } public int getRowCount() { return positionList.size(); } public int getColumnCount() { return 2; } public Class getColumnClass(int columnIndex) { switch (columnIndex) { case POSITION_COLUMN: return Integer.class; case COLOR_COLUMN: return Color.class; } return super.getColumnClass(columnIndex); } public Object getValueAt(int rowIndex, int columnIndex) { switch (columnIndex) { case POSITION_COLUMN: return positionList.get(rowIndex); case COLOR_COLUMN: return colorList.get(rowIndex); } return null; } /** * Adds a color point. * * @param color * @param position */ public void add(Color color, int position) { colorList.add(color); positionList.add(new Integer(position)); fireTableDataChanged(); } /** * Removes a color point at specified index. * * @param index */ public void remove(int index) { colorList.remove(index); positionList.remove(index); fireTableDataChanged(); } /** * Removes all color points. */ public void clear() { colorList.clear(); positionList.clear(); fireTableDataChanged(); } } libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/gradient/GradientBar.java0000644000175000017500000001766610527307546031607 0ustar gregoagregoapackage com.michaelbaranov.microba.gradient; import java.awt.Color; import javax.swing.SwingConstants; import com.michaelbaranov.microba.common.BoundedTableModel; import com.michaelbaranov.microba.common.MicrobaComponent; /** * IMPORTANT: alpha featre not implemented. Stubs only. *

* * A concrete implementation of JComponent. Displays an area filled with * gradient color (palette). The color and alpha value (transparency) is * linearly interpolated between key points. *

* The color key points are provided by the data model in combination with color * column (index) and color position column (index). Each row in the model * represents a colored key point. Color values are expected to be of type * {@link Color} and position values of type {@link Number} with integer * precision. *

* The alpha key points are provided by the alpha model in combination with * alpha column (index) and alpha position column (index). Each row in the model * represents an alpha key point. Alpha values are expected to be of type * {@link Number} with floating-point precision ranging form 0.0f (transparent) * to 1.0f (opaque) and position values of type {@link Number} with integer * precision. * * Example: * *

 * GradientBar bar = new GradientBar();
 * bar.setDataModel(myColorModel);
 * bar.setColorColumn(0);
 * bar.setColorPositionColumn(1);
 * 
 * bar.setAlphaModel(myAlphaModel);
 * bar.setAlphaColumn(1);
 * bar.setAlphaPositionColumn(0);
 * 
* * @author Michael Baranov * */ public class GradientBar extends MicrobaComponent { /** * The name of a "dataModel" property. */ public static final String PROPERTY_DATA_MODEL = "dataModel"; /** * The name of a "alphaModel" property. */ public static final String PROPERTY_ALPHA_MODEL = "alphaModel"; /** * The name of a "colorPositionColumn" property. */ public static final String PROPERTY_COLOR_POSITION_COLUMN = "colorPositionColumn"; /** * The name of a "alphaPositionColumn" property. */ public static final String PROPERTY_ALPHA_POSITION_COLUMN = "alphaPositionColumn"; /** * The name of a "colorColumn" property. */ public static final String PROPERTY_COLOR_COLUMN = "colorColumn"; /** * The name of a "alphaColumn" property. */ public static final String PROPERTY_ALPHA_COLUMN = "alphaColumn"; /** * The name of a "orientation" property. */ public static final String PROPERTY_ORIENTATION = "orientation"; private static final String uiClassID = "microba.GradientUI"; protected BoundedTableModel dataModel; protected BoundedTableModel alphaModel; protected int colorPositionColumn = 0; protected int alphaPositionColumn = 0; protected int colorColumn = 1; protected int alphaColumn = 1; protected int orientation = SwingConstants.HORIZONTAL; public String getUIClassID() { return uiClassID; } /** * Constructor. */ public GradientBar() { super(); dataModel = new DefaultGradientModel(); setFocusable(false); updateUI(); } /** * Constructor. */ public GradientBar(BoundedTableModel model) { super(); dataModel = model; setFocusable(false); updateUI(); } /** * Constructor. */ public GradientBar(BoundedTableModel model, int orientation) { super(); dataModel = model; this.orientation = orientation; setFocusable(false); updateUI(); } /** * Returns the index of the color column for the data model. * * @return index of color column * @see #setColorColumn(int) */ public int getColorColumn() { return colorColumn; } /** * Sets the index of the color column for the data model. * * @param colorColumn * index of color column * @see #getColorColumn() */ public void setColorColumn(int colorColumn) { int old = this.colorColumn; this.colorColumn = colorColumn; firePropertyChange(PROPERTY_COLOR_COLUMN, old, colorColumn); } /** * Returns the index of the alpha column for the alpha model. * * @return index of alpha column * @see #setAlphaColumn(int) */ public int getAlphaColumn() { return alphaColumn; } /** * Sets the index of the alpha column for the alpha model. * * @param alphaColumn * index of alpha column * @see #getAlphaColumn() */ public void setAlphaColumn(int alphaColumn) { int old = this.colorColumn; this.alphaColumn = alphaColumn; firePropertyChange(PROPERTY_ALPHA_COLUMN, old, alphaColumn); } /** * Regturns the current data model. The data model provides key points for * interpolation (position & color). * * @return current data model * @see #setDataModel(BoundedTableModel) * @see #getColorColumn() */ public BoundedTableModel getDataModel() { return dataModel; } /** * Sets the current data model. The data model provides key points for * interpolation (position & color). * * @param dataModel * current data model * @see #getDataModel() * @see #getColorColumn() */ public void setDataModel(BoundedTableModel dataModel) { BoundedTableModel old = this.dataModel; this.dataModel = dataModel; firePropertyChange(PROPERTY_DATA_MODEL, old, dataModel); } /** * Regturns the current alpha model. The data model provides alpha key * points for interpolation (position & alpha). * * @return current alpha model * @see #setAlphaModel(BoundedTableModel) * @see #getAlphaColumn() */ public BoundedTableModel getAlphaModel() { return alphaModel; } /** * Sets the current alpha model. The alpha model provides alpha key points * for interpolation (position & alpha). * * @param alphaModel * current alpha model * @see #getAlphaModel() * @see #getAlphaColumn() */ public void setAlphaModel(BoundedTableModel alphaModel) { BoundedTableModel old = this.alphaModel; this.alphaModel = alphaModel; firePropertyChange(PROPERTY_ALPHA_MODEL, old, alphaModel); } /** * Returns current orientation of the component. Possible values are: * * * @return orientation * @see #setOrientation(int) */ public int getOrientation() { return orientation; } /** * Sets orientation of the component. Possible values are: * * * @param orientation */ public void setOrientation(int orientation) { int old = this.orientation; this.orientation = orientation; firePropertyChange(PROPERTY_ORIENTATION, old, orientation); } /** * Returns the index of the position column for the data model. * * @return index of position column * @see #setColorPositionColumn(int) */ public int getColorPositionColumn() { return colorPositionColumn; } /** * Sets the index of the position column for the data model. * * @param positionColumn * index of position column * @see #getColorPositionColumn() */ public void setColorPositionColumn(int positionColumn) { int old = this.colorPositionColumn; this.colorPositionColumn = positionColumn; firePropertyChange(PROPERTY_COLOR_POSITION_COLUMN, old, positionColumn); } /** * Returns the index of the position column for the alpha model. * * @return index of position column * @see #setAlphaPositionColumn(int) */ public int getAlphaPositionColumn() { return alphaPositionColumn; } /** * Sets the index of the position column for the alpha model. * * @param positionColumn * index of position column * @see #getAlphaPositionColumn() */ public void setAlphaPositionColumn(int positionColumn) { int old = this.alphaPositionColumn; this.alphaPositionColumn = positionColumn; firePropertyChange(PROPERTY_ALPHA_POSITION_COLUMN, old, positionColumn); } } libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/gradienteditor/0000755000175000017500000000000010634142130027732 5ustar gregoagregoalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/gradienteditor/ui/0000755000175000017500000000000010634142130030347 5ustar gregoagregoa././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/gradienteditor/ui/GradientEditorListener.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/gradienteditor/ui/GradientEdit0000644000175000017500000000120010412660742032636 0ustar gregoagregoapackage com.michaelbaranov.microba.gradienteditor.ui; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import com.michaelbaranov.microba.gradienteditor.GradientEditor; public class GradientEditorListener implements PropertyChangeListener { private GradientEditorUI ui; private GradientEditor editor; public GradientEditorListener(GradientEditor editor, GradientEditorUI ui) { super(); this.editor = editor; this.ui = ui; } public void propertyChange(PropertyChangeEvent evt) { if (GradientEditor.PROPERTY_DATA_MODEL.equals(evt.getPropertyName())) { } } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/gradienteditor/ui/GradientEditorLayout.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/gradienteditor/ui/GradientEdit0000644000175000017500000000346710412660742032657 0ustar gregoagregoapackage com.michaelbaranov.microba.gradienteditor.ui; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; import java.awt.Insets; import java.awt.LayoutManager; import javax.swing.SwingConstants; import com.michaelbaranov.microba.gradient.GradientBar; import com.michaelbaranov.microba.gradienteditor.GradientEditor; import com.michaelbaranov.microba.marker.MarkerBar; public class GradientEditorLayout implements LayoutManager { private MarkerBar bar; private GradientBar gradient; public GradientEditorLayout(MarkerBar bar, GradientBar gradient) { this.bar = bar; this.gradient = gradient; } public void addLayoutComponent(String name, Component comp) { } public void removeLayoutComponent(Component comp) { } public Dimension preferredLayoutSize(Container parent) { return parent.getPreferredSize(); } public Dimension minimumLayoutSize(Container parent) { return parent.getMinimumSize(); } 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); } } } libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/gradienteditor/ui/basic/0000755000175000017500000000000010634142130031430 5ustar gregoagregoa././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/gradienteditor/ui/basic/BasicGradientEditorUI.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/gradienteditor/ui/basic/BasicG0000644000175000017500000001340210412660742032513 0ustar gregoagregoapackage 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)); } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/gradienteditor/ui/GradientEditorUI.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/gradienteditor/ui/GradientEdit0000644000175000017500000000023210412660742032642 0ustar gregoagregoapackage com.michaelbaranov.microba.gradienteditor.ui; import javax.swing.plaf.ComponentUI; public class GradientEditorUI extends ComponentUI{ } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/gradienteditor/GradientEditor.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/gradienteditor/GradientEditor.0000644000175000017500000001232110527307546032655 0ustar gregoagregoapackage com.michaelbaranov.microba.gradienteditor; import javax.swing.JColorChooser; import javax.swing.ListSelectionModel; import com.michaelbaranov.microba.gradient.GradientBar; import com.michaelbaranov.microba.marker.MarkerBar; import com.michaelbaranov.microba.marker.MarkerMutationModel; /** * IMPORTANT: alpha featre not implemented. Stubs only. No alpha marker bar yet. *

* * 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(); } 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; } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/gradienteditor/DefaultGradientEditorModel.javalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/gradienteditor/DefaultGradient0000644000175000017500000000606610412660742032737 0ustar gregoagregoapackage com.michaelbaranov.microba.gradienteditor; import java.awt.Color; import java.util.ArrayList; import java.util.List; import javax.swing.ListSelectionModel; import com.michaelbaranov.microba.common.AbstractBoundedTableModelWithSelection; import com.michaelbaranov.microba.marker.MarkerMutationModel; /** * A basic implementation of {@link AbstractBoundedTableModelWithSelection} and * {@link MarkerMutationModel}. Used by default by {@link GradientEditor} as a * color model, color selection model and color mutation model. * *

* 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 position = new ArrayList(32); protected List color = new ArrayList(32); public DefaultGradientEditorModel() { super(); setSelectionMode(ListSelectionModel.SINGLE_SELECTION); position.add(new Integer(0)); color.add(Color.BLACK); position.add(new Integer(255)); color.add(Color.WHITE); } public void removeMarkerAtIndex(int index) { if (isSelectedIndex(index)) { removeSelectionInterval(index, index); } position.remove(index); color.remove(index); fireTableRowsDeleted(index, index); } public int addMarkAtPosition(int pos) { position.add(new Integer(pos)); color.add(new Color((float) Math.random(), (float) Math.random(), (float) Math.random())); int index = position.size() - 1; fireTableRowsInserted(index, index); return index; } public int getLowerBound() { return 0; } public int getUpperBound() { return 255; } public int getRowCount() { return position.size(); } public int getColumnCount() { return 2; } public Class getColumnClass(int columnIndex) { switch (columnIndex) { case POSITION_COLUMN: return Integer.class; case COLOR_COLUMN: return Color.class; } return super.getColumnClass(columnIndex); } public Object getValueAt(int rowIndex, int columnIndex) { switch (columnIndex) { case POSITION_COLUMN: return position.get(rowIndex); case COLOR_COLUMN: return color.get(rowIndex); } return null; } public void setValueAt(Object aValue, int rowIndex, int columnIndex) { switch (columnIndex) { case POSITION_COLUMN: for (int i = 0; i < position.size(); i++) if (rowIndex != i && aValue.equals(position.get(i))) { return; } position.remove(rowIndex); position.add(rowIndex, aValue); fireTableCellUpdated(rowIndex, columnIndex); break; case COLOR_COLUMN: color.remove(rowIndex); color.add(rowIndex, (Color) aValue); fireTableCellUpdated(rowIndex, columnIndex); break; } } public boolean isCellEditable(int rowIndex, int columnIndex) { // protecting first 2 rows (first and last marker) from being moved return !(columnIndex == POSITION_COLUMN && rowIndex < 2); } } libmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/demo/0000755000175000017500000000000010634142130025652 5ustar gregoagregoalibmicroba-java-0.4.4.3.orig/src/main/java/com/michaelbaranov/microba/demo/Demo.java0000644000175000017500000002171311050603662027412 0ustar gregoagregoapackage com.michaelbaranov.microba.demo; import java.awt.BorderLayout; import java.awt.Color; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.beans.PropertyVetoException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.Map; import javax.swing.JApplet; import javax.swing.JColorChooser; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTabbedPane; import javax.swing.JTable; import javax.swing.SwingConstants; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import com.michaelbaranov.microba.calendar.CalendarPane; import com.michaelbaranov.microba.calendar.DatePicker; import com.michaelbaranov.microba.calendar.DatePickerCellEditor; import com.michaelbaranov.microba.calendar.HolidayPolicy; import com.michaelbaranov.microba.common.AbstractPolicy; import com.michaelbaranov.microba.common.BoundedTableModel; import com.michaelbaranov.microba.common.PolicyListener; import com.michaelbaranov.microba.gradient.GradientBar; import com.michaelbaranov.microba.gradienteditor.GradientEditor; import com.michaelbaranov.microba.marker.MarkerBar; public class Demo extends JApplet { static MarkerBar bar; static BoundedTableModel model; private static JFrame frame; private static JPanel panel; public static void main(String[] s) { Demo demo = new Demo(); demo.run(); } private void run() { frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.getContentPane().setLayout(new BorderLayout()); JTabbedPane tabs = new JTabbedPane(); tabs.addTab("CalendarPane", buildCalendarPaneTab()); tabs.addTab("Gradient", buildGradientTab()); tabs.addTab("CellEditor", buildCellEditorTab()); tabs.addTab("DatePicker", buildDatePickerTab()); frame.getContentPane().add(tabs, BorderLayout.CENTER); frame.setSize(500, 300); frame.setVisible(true); } // // public void init() { // super.init(); // System.out.println("init"); // panel = new JPanel(); // panel.setLayout(new BorderLayout()); // // JTabbedPane tabs = new JTabbedPane(); // tabs.addTab("CalendarPane", buildCalendarPaneTab()); // tabs.addTab("Gradient", buildGradientTab()); // tabs.addTab("CellEditor", buildCellEditorTab()); // tabs.addTab("DatePicker", buildDatePickerTab()); // // panel.add(tabs, BorderLayout.CENTER); // this.setContentPane(panel); // } public void start() { System.out.println("start"); super.start(); } public void stop() { System.out.println("stop"); super.stop(); } private class Hol extends AbstractPolicy implements HolidayPolicy { public String getHollidayName(Object source, Calendar date) { return null; } public boolean isHolliday(Object source, Calendar date) { return false; } public boolean isWeekend(Object source, Calendar date) { return date.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY; } } private JComponent buildCalendarPaneTab() { JPanel panel = new JPanel(); final CalendarPane calendarPane = new CalendarPane(); // calendarPane.setEnabled(false); calendarPane.setHolidayPolicy(new Hol()); Map ov = new HashMap(); ov.put(CalendarPane.COLOR_CALENDAR_GRID_FOREGROUND_ENABLED, Color.ORANGE); calendarPane.setColorOverrideMap(ov); try { calendarPane.setDate(new Date()); } catch (PropertyVetoException e) { // TODO Auto-generated catch block e.printStackTrace(); } calendarPane.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("CalendarPane:" + calendarPane.getDate()); } }); panel.setLayout(new GridBagLayout()); panel.add(calendarPane, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets( 5, 5, 5, 5), 0, 0)); panel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { calendarPane.observeMonth(2009, 4); } }); return panel; } private JComponent buildDatePickerTab() { JPanel panel = new JPanel(); final DatePicker datePicker = new DatePicker(); // datePicker.setDateFormat(new SimpleDateFormat("HH dd yyyy")); datePicker.setDateFormat(SimpleDateFormat.getDateTimeInstance()); // datePicker.setStripTime(false); datePicker.setEnabled(false); datePicker.setKeepTime(true); datePicker.setStripTime(false); datePicker.setShowNumberOfWeek(true); // datePicker.setEnabled(false); // datePicker.setPickerStyle(DatePicker.PICKER_STYLE_BUTTON); // datePicker.showButtonOnly(false); // datePicker.setToolTipText("hello!!!!"); // datePicker.setShowNumberOfWeek(true); Map ov = new HashMap(); ov.put(CalendarPane.COLOR_CALENDAR_GRID_FOREGROUND_ENABLED, Color.ORANGE); datePicker.setColorOverrideMap(ov); panel.setLayout(new GridBagLayout()); panel.add(datePicker, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets( 5, 5, 5, 5), 0, 0)); datePicker.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("DatePicker:" + datePicker.getDate()); } }); panel.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent e) { try { datePicker.setDate(null); } catch (PropertyVetoException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } public void mouseEntered(MouseEvent e) { // TODO Auto-generated method stub } public void mouseExited(MouseEvent e) { // TODO Auto-generated method stub } public void mousePressed(MouseEvent e) { // TODO Auto-generated method stub } public void mouseReleased(MouseEvent e) { // TODO Auto-generated method stub } }); return panel; } private JComponent buildCellEditorTab() { JPanel panel = new JPanel(); DatePicker datePicker = new DatePicker(); datePicker.setDropdownFocusable(true); DatePickerCellEditor cellEditor = new DatePickerCellEditor(datePicker); cellEditor.setClickCountToStart(2); JTable table = new JTable(100, 3); table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); JScrollPane scrollPane = new JScrollPane(table); table.getColumnModel().getColumn(0).setCellEditor(cellEditor); panel.setLayout(new GridBagLayout()); panel.add(scrollPane, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets( 5, 5, 5, 5), 0, 0)); return panel; } private JComponent buildGradientTab() { JPanel panel = new JPanel(); GradientBar gradient; GradientEditor editor; JColorChooser colorChooser; colorChooser = new JColorChooser(); editor = new GradientEditor(); // editor.setOrientation(SwingConstants.VERTICAL); ColorAdaptor adaptor = new ColorAdaptor(editor, colorChooser); panel.add(editor, BorderLayout.NORTH); panel.add(colorChooser, BorderLayout.CENTER); MarkerBar bar = new MarkerBar(); bar.setDataModel(editor.getDataModel()); bar.setPositionColumn(editor.getColorPositionColumn()); bar.setColorColumn(editor.getColorColumn()); bar.setFliped(true); bar.setOrientation(SwingConstants.VERTICAL); panel.add(bar, BorderLayout.EAST); return panel; } private static class ColorAdaptor implements ChangeListener, ListSelectionListener { private GradientEditor editor; private JColorChooser chooser; public ColorAdaptor(GradientEditor editor, JColorChooser chooser) { super(); this.editor = editor; this.chooser = chooser; editor.getColorSelectionModel().addListSelectionListener(this); chooser.getSelectionModel().addChangeListener(this); } public void valueChanged(ListSelectionEvent e) { int index = editor.getColorSelectionModel().getLeadSelectionIndex(); // System.out.println(index); // System.out.println(e.getFirstIndex()); // System.out.println(e.getLastIndex()); // System.out.println("-------"); Color c = (Color) editor.getDataModel().getValueAt(index, editor.getColorColumn()); chooser.setColor(c); } public void stateChanged(ChangeEvent e) { if (!editor.getColorSelectionModel().isSelectionEmpty()) { int index = editor.getColorSelectionModel() .getLeadSelectionIndex(); editor.getDataModel().setValueAt(chooser.getColor(), index, editor.getColorColumn()); } } } } libmicroba-java-0.4.4.3.orig/license.txt0000644000175000017500000000277510412660742017333 0ustar gregoagregoaCopyright (c) 2005-2006, Michael Baranov All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the MICROBA, MICHAELBARANOV.COM, MICHAEL BARANOV nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.libmicroba-java-0.4.4.3.orig/build.xml0000644000175000017500000001015311050604146016751 0ustar gregoagregoa IMPORTANT: Assuming libraries in lib-compiletime directory.

libmicroba-java-0.4.4.3.orig/readme.txt0000644000175000017500000000306110502757464017143 0ustar gregoagregoaTIPS & TRICKS: 1. In Applet#init(), call Microba.init() to handle browser refresh button correctly. CONTRIBUTORS: (random order) * Alessandro Falappa: Italian translation * Frido van Orden, Henk van Voorthuijsen: Dutch translation * Gustavo Santucho: Spanish translation * Gregory Kaczmarczyk: Polish translation * Philipp Meier: German translation * Claus Nielsen: Danish translation * Felix Bordea: Romanian translation * David Ekholm: Swedish translation TRANSLATION: For the list of supported language translations, look into com\michaelbaranov\microba\calendar\DefaultCalendarResources.properties Help translating needed! Please contribute! Send the translations to: michael[.]baranov[@]gmail[.]com KNOWN PROBLEMS: 1. DatePicker: while editing the field, enter arbitrary string after the last formatted character, position cursor anywhere past the last formatted character, press up or down key -> exception is raised: java.lang.IllegalArgumentException: Invalid index ... Reason: a bug in Sun's javax.swing.text.InternationalFormatter. 2. DatePicker: set the style to STYLE_MODERN, open dropdown, click month combo box -> dropdown is hidden OR can not close dropdown anymore OR exception (depends on JRE version). Reason: a bug in Sun's javax.swing.JPopupMenu, when using "popup in popup". 3. DatePicker: if a heavy-weight popup is used to display dropdown (for ex. it goes outside a JFrame), dropdown does not receive keyboard focus anymore. Reason: a bug in Sun's focus handling routines.