tkormann    01/10/04 01:25:47

  Modified:    sources/org/apache/batik/swing/gvt JGVTComponent.java
                        TextSelectionManager.java
  Log:
  Add few methods to control the color and the XOR mode of the selection overlay.
  
  Revision  Changes    Path
  1.19      +52 -1     xml-batik/sources/org/apache/batik/swing/gvt/JGVTComponent.java
  
  Index: JGVTComponent.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/gvt/JGVTComponent.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- JGVTComponent.java        2001/10/03 16:08:19     1.18
  +++ JGVTComponent.java        2001/10/04 08:25:47     1.19
  @@ -53,7 +53,7 @@
    * This class represents a component which can display a GVT tree.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
  - * @version $Id: JGVTComponent.java,v 1.18 2001/10/03 16:08:19 tkormann Exp $
  + * @version $Id: JGVTComponent.java,v 1.19 2001/10/04 08:25:47 tkormann Exp $
    */
   public class JGVTComponent extends JComponent {
   
  @@ -294,6 +294,57 @@
       ////////////////////////////////////////////////////////////////////////
       // Selection methods
       ////////////////////////////////////////////////////////////////////////
  +
  +    /**
  +     * Sets the color of the selection overlay to the specified color.
  +     *
  +     * @param color the new color of the selection overlay
  +     */
  +    public void setSelectionOverlayColor(Color color) {
  +     textSelectionManager.setSelectionOverlayColor(color);
  +    }
  +
  +    /**
  +     * Returns the color of the selection overlay.
  +     */
  +    public Color getSelectionOverlayColor() {
  +     return textSelectionManager.getSelectionOverlayColor();
  +    }
  +
  +    /**
  +     * Sets the color of the outline of the selection overlay to the specified
  +     * color.
  +     *
  +     * @param color the new color of the outline of the selection overlay 
  +     */
  +    public void setSelectionOverlayStrokeColor(Color color) {
  +     textSelectionManager.setSelectionOverlayStrokeColor(color);
  +    }
  +
  +    /**
  +     * Returns the color of the outline of the selection overlay.
  +     */
  +    public Color getSelectionOverlayStrokeColor() {
  +     return textSelectionManager.getSelectionOverlayStrokeColor();
  +    }
  +
  +    /**
  +     * Sets whether or not the selection overlay will be painted in XOR mode,
  +     * depending on the specified parameter.
  +     *
  +     * @param state true implies the selection overlay will be in XOR mode 
  +     */
  +    public void setSelectionOverlayXORMode(boolean state) {
  +     textSelectionManager.setSelectionOverlayXORMode(state);
  +    }
  +
  +    /**
  +     * Returns true if the selection overlay is painted in XOR mode, false
  +     * otherwise.
  +     */
  +    public boolean isSelectionOverlayXORMode() {
  +     return textSelectionManager.isSelectionOverlayXORMode();
  +    }
   
       /**
        * Sets the selection to the specified start and end mark.
  
  
  
  1.11      +81 -12    
xml-batik/sources/org/apache/batik/swing/gvt/TextSelectionManager.java
  
  Index: TextSelectionManager.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/swing/gvt/TextSelectionManager.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- TextSelectionManager.java 2001/10/03 16:08:19     1.10
  +++ TextSelectionManager.java 2001/10/04 08:25:47     1.11
  @@ -36,7 +36,7 @@
    * This class represents an object which manage GVT text nodes selection.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
  - * @version $Id: TextSelectionManager.java,v 1.10 2001/10/03 16:08:19 tkormann Exp $
  + * @version $Id: TextSelectionManager.java,v 1.11 2001/10/04 08:25:47 tkormann Exp $
    */
   public class TextSelectionManager {
   
  @@ -86,6 +86,22 @@
       protected SelectionListener textSelectionListener;
   
       /**
  +     * The color of the selection overlay.
  +     */
  +    protected Color selectionOverlayColor = new Color(200, 200, 255, 100);
  +
  +    /**
  +     * The color of the outline of the selection overlay.
  +     */
  +    protected Color selectionOverlayStrokeColor = new Color(255, 255, 255, 255);
  +
  +    /**
  +     * A flag bit that indicates whether or not the selection overlay is painted
  +     * in XOR mode.
  +     */
  +    protected boolean xorMode = true;
  +
  +    /**
        * Creates a new TextSelectionManager.
        */
       public TextSelectionManager(JGVTComponent comp,
  @@ -102,6 +118,57 @@
       }
   
       /**
  +     * Sets the color of the selection overlay to the specified color.
  +     *
  +     * @param color the new color of the selection overlay
  +     */
  +    public void setSelectionOverlayColor(Color color) {
  +     this.selectionOverlayColor = color;
  +    }
  +
  +    /**
  +     * Returns the color of the selection overlay.
  +     */
  +    public Color getSelectionOverlayColor() {
  +     return selectionOverlayColor;
  +    }
  +
  +    /**
  +     * Sets the color of the outline of the selection overlay to the specified
  +     * color.
  +     *
  +     * @param color the new color of the outline of the selection overlay 
  +     */
  +    public void setSelectionOverlayStrokeColor(Color color) {
  +     this.selectionOverlayStrokeColor = color;
  +    }
  +
  +    /**
  +     * Returns the color of the outline of the selection overlay.
  +     */
  +    public Color getSelectionOverlayStrokeColor() {
  +     return selectionOverlayStrokeColor;
  +    }
  +
  +    /**
  +     * Sets whether or not the selection overlay will be painted in XOR mode,
  +     * depending on the specified parameter.
  +     *
  +     * @param state true implies the selection overlay will be in XOR mode 
  +     */
  +    public void setSelectionOverlayXORMode(boolean state) {
  +     this.xorMode = state;
  +    }
  +
  +    /**
  +     * Returns true if the selection overlay is painted in XOR mode, false
  +     * otherwise.
  +     */
  +    public boolean isSelectionOverlayXORMode() {
  +     return xorMode;
  +    }
  +
  +    /**
        * Returns the selection overlay.
        */
       public Overlay getSelectionOverlay() {
  @@ -239,9 +306,6 @@
           return outset(s.getBounds(), 1);
       }
   
  -    static final Color fillColor   = new Color(200, 200, 255, 100);
  -    static final Color strokeColor = new Color(255, 255, 255, 255);
  -
       /**
        * The selection overlay.
        */
  @@ -256,15 +320,20 @@
                   Shape s = at.createTransformedShape(selectionHighlight);
   
                   Graphics2D g2d = (Graphics2D)g;
  -
  -                // g2d.setXORMode(Color.white);
  -                // g2d.setColor(Color.black);
  -                g2d.setColor(fillColor);
  +             if (xorMode) {
  +                 int red = 255 - selectionOverlayColor.getRed();
  +                 int green = 255 - selectionOverlayColor.getGreen();
  +                 int blue = 255 - selectionOverlayColor.getBlue();
  +                 g2d.setXORMode(new Color(red, green, blue));
  +             }
  +                g2d.setColor(selectionOverlayColor);
                   g2d.fill(s);
  -
  -                g2d.setStroke(new java.awt.BasicStroke(1.0f));
  -                g2d.setColor(strokeColor);
  -                g2d.draw(s);
  +     
  +             if (selectionOverlayStrokeColor != null) {
  +                 g2d.setStroke(new java.awt.BasicStroke(1.0f));
  +                 g2d.setColor(selectionOverlayStrokeColor);
  +                 g2d.draw(s);
  +             }
               }
           }
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to