[Spedit-commits] CVS: prototype/Sources/net/sourceforge/spedit/ui AttributesDisplay.java,1.2,1.3 Blo
Status: Planning
Brought to you by:
krunte
|
From: S?bastien P. <kaz...@us...> - 2001-11-27 10:31:45
|
Update of /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui
In directory usw-pr-cvs1:/tmp/cvs-serv25172/sourceforge/spedit/ui
Modified Files:
AttributesDisplay.java BlockView.java LabelView.java
ParagraphView.java WrapperView.java
Removed Files:
TableView.java
Log Message:
Apart from the new SPML package many improvements have been done both
to the StyleSheet and to the Views. There is now a basic layout management
in the Views using the "stick" element of Padding style properties groups
in XSS.
One of the interesting aspect is the Pool class that gathers resources
allowing the editor to dynamically manage resources. This is particulary
useful for images/icons.
Index: AttributesDisplay.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui/AttributesDisplay.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** AttributesDisplay.java 2001/11/21 11:02:04 1.2
--- AttributesDisplay.java 2001/11/27 10:31:41 1.3
***************
*** 3,7 ****
// Module : GUI-Views
// ClassName : AttributesDisplay
! // Version : 0.50
// Type :
//
--- 3,7 ----
// Module : GUI-Views
// ClassName : AttributesDisplay
! // Version : 0.90
// Type :
//
***************
*** 14,19 ****
// ----------------------------------------------------------------------------
// Creation date : 13-Nov-2001
! // Last mod. : 13-Nov-2001
// History :
// 13-Nov-2001 First implementation.(sp)
//
--- 14,22 ----
// ----------------------------------------------------------------------------
// Creation date : 13-Nov-2001
! // Last mod. : 21-Nov-2001
// History :
+ // 21-Nov-2001 Much cleaner for sublacssing, only displays
+ // children so display intergrated well with the
+ // WrapperView, imprtoved documentation.(sp)
// 13-Nov-2001 First implementation.(sp)
//
***************
*** 41,44 ****
--- 44,53 ----
* subclass <code>AttributesDisplay</code> and adapt it to your needs. By default
* it will display a table with the different attributes.</p>
+ *
+ * <p>Each <code>AttributesDisplay</code> has a reference to both the containing
+ * view and thre reprensented element (in Swing sense). This allows the attributes
+ * display to reach the style information located in the represented element.
+ * Note that at instanciation time of the attributes display the element has
+ * already an initialized stylesheet.</p>
*/
public class AttributesDisplay extends JPanel
***************
*** 46,57 ****
// PROTECTED_______________________________________________________________
! protected JTable table;
! protected AttributesModel model;
! protected WrapperView view;
!
! protected int xOffset=0;
! protected int yOffset=0;
! protected int xSize=0;
! protected int ySize=0;
//-------------------------------------------------------------------------
--- 55,60 ----
// PROTECTED_______________________________________________________________
! protected WrapperView view;
! protected XMLElementWrapper element;
//-------------------------------------------------------------------------
***************
*** 68,108 ****
{
super();
- this.model = new AttributesModel(element);
- this.table = new JTable(model);
this.view = view;
! add(table);
}
! public void paint(Graphics g)
{
! //System.out.println("Repaiting "+model.element.getName());
! paintChildren(g);
}
! /**
! * The offset is used to translate the graphics to paint the component
! * at the right location. This is allow to move the component without having
! * to relayout everythin, thus gaining precious time in the repaint mechanism.
! * @param The offset on the X axis in pixels
! * @param The offset on the Y axis in pixels
! */
! public void setOffset(int x, int y)
{
! this.xOffset = x;
! this.yOffset = y;
}
- /**
- * This <code>setSize</code> redefinition does nothing if the size has not
- * been changed.
- * NOTE: THIS MAY NOT BE REQUIRED, SHOULD HAVE A LOOK INSIDE COMPONENT
-
- public void setBounds(int x, int y, int w, int h)
- {
- if ( x!=xOffset || y!=yOffset || w!=xSize || h!=ySize )
- { super.setBounds(x,y,w,h); xOffset=x ; yOffset=y ; xSize=w ; ySize=h ; }
- }*/
-
-
//-------------------------------------------------------------------------
//
--- 71,91 ----
{
super();
this.view = view;
! this.element = element;
! setFont(view.getStyleSheet().font);
! init();
}
! protected void init()
{
! add(new JTable(new AttributesModel(element)));
}
! public void paint(Graphics g)
{
! //System.out.println("Repaiting "+model.element.getName());
! paintChildren(g);
}
//-------------------------------------------------------------------------
//
***************
*** 118,122 ****
{
public final boolean HORIZONTAL=true;
! public final boolean VERTICAL=true;
protected XMLElementWrapper element;
protected boolean orientation=HORIZONTAL;
--- 101,105 ----
{
public final boolean HORIZONTAL=true;
! public final boolean VERTICAL=false;
protected XMLElementWrapper element;
protected boolean orientation=HORIZONTAL;
Index: BlockView.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui/BlockView.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** BlockView.java 2001/11/01 15:41:43 1.1
--- BlockView.java 2001/11/27 10:31:41 1.2
***************
*** 3,7 ****
// Module : GUI-Views
// ClassName : BlockView
! // Version : 0.08
// Type :
//
--- 3,7 ----
// Module : GUI-Views
// ClassName : BlockView
! // Version : 0.80
// Type :
//
***************
*** 14,19 ****
// ----------------------------------------------------------------------------
// Creation date : 27-Sep-2001
! // Last mod. : 27-Sep-2001
// History :
// 27-Sep-2001 First implementation. (SP)
//
--- 14,20 ----
// ----------------------------------------------------------------------------
// Creation date : 27-Sep-2001
! // Last mod. : 27-Nov-2001
// History :
+ // 27-Nov-2001 Updated inset accession.(sp)
// 27-Sep-2001 First implementation. (SP)
//
***************
*** 86,144 ****
//-------------------------------------------------------------------------
- /**
- * Transforms the given shape that corresponds to the container view to
- * the destination view.
- */
- protected Shape adjustC2V(Shape shape)
- {
- Rectangle2D bounds = (Rectangle2D)shape.getBounds();
- double x = bounds.getX()+styleSheet.paddingLeft;
- double y = bounds.getY()+styleSheet.paddingTop;
- double w = bounds.getWidth();
- double h = bounds.getHeight();
- bounds.setRect(x,y,w,h);
- return bounds;
- }
-
- /**
- * Transforms the given shape that corresponds to the container view to
- * the destination view.
- */
- protected Shape adjustV2C(Shape shape)
- {
- Rectangle2D bounds = (Rectangle2D)shape.getBounds();
- double x = bounds.getX()-styleSheet.paddingLeft;
- double y = bounds.getY()-styleSheet.paddingTop;
- double w = bounds.getWidth();
- double h = bounds.getHeight();
- bounds.setRect(x,y,w,h);
- return bounds;
- }
- public int viewToModel(float x, float y, Shape a)
- { return super.viewToModel(x-styleSheet.paddingLeft,y-styleSheet.paddingTop,a); }
-
- public int viewToModel(float x, float y, Shape a, Position.Bias[] biasReturn)
- { return super.viewToModel(x-styleSheet.paddingLeft,y-styleSheet.paddingTop,a,biasReturn); }
-
- public Shape modelToView(int p0, Position.Bias b0, int p1, Position.Bias b1, Shape a)
- throws BadLocationException
- {
- Rectangle2D shape = (Rectangle2D) super.modelToView(p0,b0,p1,b1,a);
- return adjustC2V(shape);
- }
-
- public Shape modelToView(int pos, Shape a)
- throws BadLocationException
- {
- Rectangle2D shape = (Rectangle2D) super.modelToView(pos,a);
- return adjustC2V(shape);
- }
-
- public Shape modelToView(int pos, Shape a, Position.Bias b)
- throws BadLocationException
- {
- Rectangle2D shape = (Rectangle2D) super.modelToView(pos,a,b);
- return adjustC2V(shape);
- }
//-------------------------------------------------------------------------
//
--- 87,90 ----
***************
*** 148,161 ****
public short getLeftInset()
! { return styleSheet.paddingLeft; }
public short getTopInset()
! { return styleSheet.paddingTop; }
public short getBottomInset()
! { return styleSheet.paddingBottom; }
public short getRightInset()
! { return styleSheet.paddingRight; }
public float getAlignment(int axis)
--- 94,107 ----
public short getLeftInset()
! { return WrapperView.getLeftInset(styleSheet);}
public short getTopInset()
! { return WrapperView.getTopInset(styleSheet); }
public short getBottomInset()
! { return WrapperView.getBottomInset(styleSheet); }
public short getRightInset()
! { return WrapperView.getRightInset(styleSheet); }
public float getAlignment(int axis)
Index: LabelView.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui/LabelView.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** LabelView.java 2001/11/15 10:49:43 1.2
--- LabelView.java 2001/11/27 10:31:41 1.3
***************
*** 3,7 ****
// Module : GUI-Views
// ClassName : BlockView
! // Version : 0.08
// Type :
//
--- 3,7 ----
// Module : GUI-Views
// ClassName : BlockView
! // Version : 0.80
// Type :
//
***************
*** 14,19 ****
// ----------------------------------------------------------------------------
// Creation date : 27-Sep-2001
! // Last mod. : 07-Nov-2001
// History :
// 07-Nov-2001 Fixed selcetion problem. The solution was
// to copy the sourcecode from the JDK 1.3.1 and modify
--- 14,20 ----
// ----------------------------------------------------------------------------
// Creation date : 27-Sep-2001
! // Last mod. : 27-Nov-2001
// History :
+ // 27-Nov-2001 Updated inset accession.(sp)
// 07-Nov-2001 Fixed selcetion problem. The solution was
// to copy the sourcecode from the JDK 1.3.1 and modify
***************
*** 88,92 ****
int p1 = getEndOffset();
Rectangle alloc = (bounds instanceof Rectangle) ? (Rectangle)bounds : bounds.getBounds();
! Shape adjusted = adjustC2V(bounds);
Color bg = getBackground();
Color fg = getForeground();
--- 89,93 ----
int p1 = getEndOffset();
Rectangle alloc = (bounds instanceof Rectangle) ? (Rectangle)bounds : bounds.getBounds();
! Shape adjusted = WrapperView.translateNestedToView(bounds, styleSheet);
Color bg = getBackground();
Color fg = getForeground();
***************
*** 103,107 ****
{
((LayeredHighlighter)h).paintLayeredHighlights
! (g, p0, p1, adjustV2C(bounds), tc, this);
}
}
--- 104,108 ----
{
((LayeredHighlighter)h).paintLayeredHighlights
! (g, p0, p1, WrapperView.translateViewToNested(bounds, styleSheet), tc, this);
}
}
***************
*** 171,235 ****
//-------------------------------------------------------------------------
//
! // Model-View
//
//-------------------------------------------------------------------------
/**
- * Transforms the given shape that corresponds to the container view to
- * the destination view.
- */
- protected Shape adjustC2V(Shape shape)
- {
- Rectangle2D bounds = (Rectangle2D)shape.getBounds();
- double x = bounds.getX()+styleSheet.paddingLeft;
- double y = bounds.getY()+styleSheet.paddingTop;
- double w = bounds.getWidth();
- double h = bounds.getHeight();
- bounds.setRect(x,y,w,h);
- return bounds;
- }
-
- /**
- * Transforms the given shape that corresponds to the container view to
- * the destination view.
- */
- protected Shape adjustV2C(Shape shape)
- {
- Rectangle2D bounds = (Rectangle2D)shape.getBounds();
- double x = bounds.getX()-styleSheet.paddingLeft;
- double y = bounds.getY()-styleSheet.paddingTop;
- double w = bounds.getWidth();
- double h = bounds.getHeight();
- bounds.setRect(x,y,w,h);
- return bounds;
- }
- public int viewToModel(float x, float y, Shape a)
- { return super.viewToModel(x-styleSheet.paddingLeft,y-styleSheet.paddingTop,a); }
-
- public int viewToModel(float x, float y, Shape a, Position.Bias[] biasReturn)
- { return super.viewToModel(x-styleSheet.paddingLeft,y-styleSheet.paddingTop,a,biasReturn); }
-
- public Shape modelToView(int p0, Position.Bias b0, int p1, Position.Bias b1, Shape a)
- throws BadLocationException
- {
- Rectangle2D shape = (Rectangle2D) super.modelToView(p0,b0,p1,b1,a);
- return adjustC2V(shape);
- }
-
- public Shape modelToView(int pos, Shape a)
- throws BadLocationException
- {
- Rectangle2D shape = (Rectangle2D) super.modelToView(pos,a);
- return adjustC2V(shape);
- }
-
- public Shape modelToView(int pos, Shape a, Position.Bias b)
- throws BadLocationException
- {
- Rectangle2D shape = (Rectangle2D) super.modelToView(pos,a,b);
- return adjustC2V(shape);
- }
-
- /**
* Fetch the background color to use to render the
* glyphs. If there is no background color, null should
--- 172,180 ----
//-------------------------------------------------------------------------
//
! // Style properties
//
//-------------------------------------------------------------------------
/**
* Fetch the background color to use to render the
* glyphs. If there is no background color, null should
***************
*** 311,324 ****
public short getLeftInset()
! { return styleSheet.paddingLeft; }
public short getTopInset()
! { return styleSheet.paddingTop; }
public short getBottomInset()
! { return styleSheet.paddingBottom; }
public short getRightInset()
! { return styleSheet.paddingRight; }
--- 256,269 ----
public short getLeftInset()
! { return WrapperView.getLeftInset(styleSheet);}
public short getTopInset()
! { return WrapperView.getTopInset(styleSheet); }
public short getBottomInset()
! { return WrapperView.getBottomInset(styleSheet); }
public short getRightInset()
! { return WrapperView.getRightInset(styleSheet); }
Index: ParagraphView.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui/ParagraphView.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ParagraphView.java 2001/11/15 10:49:43 1.2
--- ParagraphView.java 2001/11/27 10:31:41 1.3
***************
*** 3,7 ****
// Module : GUI-Views
// ClassName : ParagraphView
! // Version : 0.08
// Type :
//
--- 3,7 ----
// Module : GUI-Views
// ClassName : ParagraphView
! // Version : 0.80
// Type :
//
***************
*** 11,20 ****
// URL : <http://SPEdit.sourceforge.net>
// ----------------------------------------------------------------------------
! // Authors : Sebastien Pierre <sp...@is...>
// ----------------------------------------------------------------------------
// Creation date : 27-Sep-2001
! // Last mod. : 27-Sep-2001
// History :
! // 27-Sep-2001 First implementation. (SP)
//
// Notes :
--- 11,21 ----
// URL : <http://SPEdit.sourceforge.net>
// ----------------------------------------------------------------------------
! // Authors : Sbastien Pierre <sp...@is...>
// ----------------------------------------------------------------------------
// Creation date : 27-Sep-2001
! // Last mod. : 27-Nov-2001
// History :
! // 27-Nov-2001 Updated inset accession.(sp)
! // 27-Sep-2001 First implementation. (sp)
//
// Notes :
***************
*** 84,142 ****
//-------------------------------------------------------------------------
- /**
- * Transforms the given shape that corresponds to the container view to
- * the destination view.
- */
- protected Shape adjustC2V(Shape shape)
- {
- Rectangle2D bounds = (Rectangle2D)shape.getBounds();
- double x = bounds.getX()+styleSheet.paddingLeft;
- double y = bounds.getY()+styleSheet.paddingTop;
- double w = bounds.getWidth();
- double h = bounds.getHeight();
- bounds.setRect(x,y,w,h);
- return bounds;
- }
-
- /**
- * Transforms the given shape that corresponds to the container view to
- * the destination view.
- */
- protected Shape adjustV2C(Shape shape)
- {
- Rectangle2D bounds = (Rectangle2D)shape.getBounds();
- double x = bounds.getX()-styleSheet.paddingLeft;
- double y = bounds.getY()-styleSheet.paddingTop;
- double w = bounds.getWidth();
- double h = bounds.getHeight();
- bounds.setRect(x,y,w,h);
- return bounds;
- }
- public int viewToModel(float x, float y, Shape a)
- { return super.viewToModel(x-styleSheet.paddingLeft,y-styleSheet.paddingTop,a); }
-
- public int viewToModel(float x, float y, Shape a, Position.Bias[] biasReturn)
- { return super.viewToModel(x-styleSheet.paddingLeft,y-styleSheet.paddingTop,a,biasReturn); }
-
- public Shape modelToView(int p0, Position.Bias b0, int p1, Position.Bias b1, Shape a)
- throws BadLocationException
- {
- Rectangle2D shape = (Rectangle2D) super.modelToView(p0,b0,p1,b1,a);
- return adjustC2V(shape);
- }
-
- public Shape modelToView(int pos, Shape a)
- throws BadLocationException
- {
- Rectangle2D shape = (Rectangle2D) super.modelToView(pos,a);
- return adjustC2V(shape);
- }
-
- public Shape modelToView(int pos, Shape a, Position.Bias b)
- throws BadLocationException
- {
- Rectangle2D shape = (Rectangle2D) super.modelToView(pos,a,b);
- return adjustC2V(shape);
- }
//-------------------------------------------------------------------------
//
--- 85,88 ----
***************
*** 144,159 ****
//
//-------------------------------------------------------------------------
!
public short getLeftInset()
! { return styleSheet.paddingLeft; }
public short getTopInset()
! { return styleSheet.paddingTop; }
public short getBottomInset()
! { return styleSheet.paddingBottom; }
public short getRightInset()
! { return styleSheet.paddingRight; }
public float getAlignment(int axis)
--- 90,105 ----
//
//-------------------------------------------------------------------------
!
public short getLeftInset()
! { return WrapperView.getLeftInset(styleSheet);}
public short getTopInset()
! { return WrapperView.getTopInset(styleSheet); }
public short getBottomInset()
! { return WrapperView.getBottomInset(styleSheet); }
public short getRightInset()
! { return WrapperView.getRightInset(styleSheet); }
public float getAlignment(int axis)
Index: WrapperView.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui/WrapperView.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** WrapperView.java 2001/11/21 11:02:04 1.4
--- WrapperView.java 2001/11/27 10:31:41 1.5
***************
*** 1,8 ****
// ---------------------------------------------------@RisingSun//Java//1.0//EN
! // Project : SPEdit-Prototypes
// Module : GUI-Views
// ClassName : BlockView
! // Version : 0.50
! // Type :
//
// ThreadSafe : Nope
--- 1,8 ----
// ---------------------------------------------------@RisingSun//Java//1.0//EN
! // Project : SPEdit
// Module : GUI-Views
// ClassName : BlockView
! // Version : 0.80
! // Type : View extension wrapper
//
// ThreadSafe : Nope
***************
*** 14,19 ****
// ----------------------------------------------------------------------------
// Creation date : 19-Oct-2001
! // Last mod. : 19-Nov-2001
// History :
// 19-Nov-2001 Prelimiary sluggish AttributesDisplay
// implementation.(sp)
--- 14,23 ----
// ----------------------------------------------------------------------------
// Creation date : 19-Oct-2001
! // Last mod. : 27-Nov-2001
// History :
+ // 27-Nov-2001 Added inset utility methods.(sp)
+ // 22-Nov-2001 Enable Python environment introspection
+ // when assigning attributesDisplay in setParent.(sp)
+ // 21-Nov-2001 Support for the newlyCreated flag.(sp)
// 19-Nov-2001 Prelimiary sluggish AttributesDisplay
// implementation.(sp)
***************
*** 42,49 ****
--- 46,55 ----
import java.util.*;
import java.text.*;
+ import org.python.util.*;
import javax.swing.text.*;
import javax.swing.event.*;
import javax.swing.ImageIcon;
import net.sourceforge.spedit.core.*;
+ import net.sourceforge.spedit.app.*;
//-----------------------------------------------------------------------------
***************
*** 68,75 ****
// PUBLIC__________________________________________________________________
// PROTECTED_______________________________________________________________
protected View nested;
- protected AttributesDisplay attributesDisplay;
protected String nestedName;
--- 74,82 ----
// PUBLIC__________________________________________________________________
+ public static int MIN_HEIGHT = 10;
+
// PROTECTED_______________________________________________________________
protected View nested;
protected String nestedName;
***************
*** 128,142 ****
protected void init()
{
- //XMLElementWrapper is the only one that has attributes
- if ( element instanceof XMLElementWrapper )
- {
- if ( ((XMLElementWrapper)element).getXMLElement().getAttributes().size()>0 )
- { attributesDisplay = new AttributesDisplay((XMLElementWrapper)element, this); }
- else
- { attributesDisplay = null; }
- }
- else
- { attributesDisplay = null; }
styleSheet = new StyleSheet("empty", this);
}
--- 135,140 ----
protected void init()
{
styleSheet = new StyleSheet("empty", this);
+ styleSheet.attributesDisplay = null;
}
***************
*** 146,151 ****
protected void finalize() throws Throwable
{
! if (attributesDisplay!=null && getContainer()!=null)
! { getContainer().remove(attributesDisplay); }
}
--- 144,149 ----
protected void finalize() throws Throwable
{
! if (styleSheet.attributesDisplay!=null && getContainer()!=null)
! { getContainer().remove(styleSheet.attributesDisplay); }
}
***************
*** 166,172 ****
Rectangle2D r = (Rectangle2D)s.getBounds();
! if ( getStartOffset()>=getEndOffset()-1 )
! { g.setColor(new Color(200,200,150));
! gg.fill(r); }
//We udpate the view bounds
--- 164,171 ----
Rectangle2D r = (Rectangle2D)s.getBounds();
! //This will store the title bounds in case of "stick" padding property
! int title_ul=0, title_ur=0, title_ll=0, title_lr=0;
! //Attributes display bounds, same rore as title bounds.
! int attributes_ul=0, attributes_ur=0, attributes_ll=0, attributes_lr=0;
//We udpate the view bounds
***************
*** 174,181 ****
{ viewBounds=r; refreshBounds=false; }
- //We paint the nested view
- if (!collapsed)
- { nested.paint(g,s); }
-
//And we draw the wrapper attributes
if (selected)
--- 173,176 ----
***************
*** 185,193 ****
}
if (focused)
{
! g.setColor(Color.pink);
gg.draw(r);
! }
//We draw the border
--- 180,196 ----
}
+ //We draw the focus highlight
if (focused)
{
! g.setColor(Color.blue);
gg.draw(r);
! }
!
! //We paint a specific color if the element has been newly created
! if (((XMLNode)element).hasInformation() && ((XMLNode)element).getInformation().isNewlyCreated() )
! {
! g.setColor(new Color(240,200,150));
! gg.fill(r);
! }
//We draw the border
***************
*** 204,207 ****
--- 207,211 ----
if ( isCollapsed() )
{
+ //We draw the collapsed expander in case it has been defined in the stylesheet
if ( styleSheet.hasExpander )
{
***************
*** 214,219 ****
(int)(r.getY()+12+(r.getHeight()-12)/2));
//We hide the attributes display
! if (attributesDisplay!=null)
! { attributesDisplay.setVisible(false); }
}
//If the view is expanded
--- 218,223 ----
(int)(r.getY()+12+(r.getHeight()-12)/2));
//We hide the attributes display
! if (styleSheet.attributesDisplay!=null)
! { styleSheet.attributesDisplay.setVisible(false); }
}
//If the view is expanded
***************
*** 221,227 ****
{
//We make sure that the attributesDisplay is visible
! if (attributesDisplay!=null && attributesDisplay.getParent()!=null)
! { attributesDisplay.setVisible(true); }
if ( styleSheet.hasExpander )
{
--- 225,232 ----
{
//We make sure that the attributesDisplay is visible
! if (styleSheet.attributesDisplay!=null && styleSheet.attributesDisplay.getParent()!=null)
! { styleSheet.attributesDisplay.setVisible(true); }
+ //We draw the expander
if ( styleSheet.hasExpander )
{
***************
*** 229,232 ****
--- 234,238 ----
}
+ //We draw the title
if ( styleSheet.title!=null )
{
***************
*** 237,255 ****
(int)r.getY()+styleSheet.titlePaddingTop+styleSheet.titleFont.getSize());
}
}
//We take care of the attributes display
! if ( attributesDisplay!=null )
{
! if (attributesDisplay.getParent()==null && getContainer()!=null)
! { getContainer().add(attributesDisplay); }
Rectangle2D bounds = getBounds();
! Dimension psize = attributesDisplay.getPreferredSize();
! attributesDisplay.setOffset((int)bounds.getX(), (int)bounds.getY());
! attributesDisplay.setSize((int)psize.getWidth(), (int)psize.getHeight());
! attributesDisplay.setBounds((int)bounds.getX(), (int)bounds.getY(),
(int)psize.getWidth(), (int)psize.getHeight());
- //attributesDisplay.repaint();
}
}
--- 243,267 ----
(int)r.getY()+styleSheet.titlePaddingTop+styleSheet.titleFont.getSize());
}
+ //We draw the nested view
+ nested.paint(g,s);
}
//We take care of the attributes display
! if ( styleSheet.attributesDisplay!=null )
{
! if (styleSheet.attributesDisplay.getParent()==null && getContainer()!=null)
! { getContainer().add(styleSheet.attributesDisplay); }
Rectangle2D bounds = getBounds();
! Dimension psize = styleSheet.attributesDisplay.getPreferredSize();
! styleSheet.attributesDisplay.setBounds((int)bounds.getX(), (int)bounds.getY(),
(int)psize.getWidth(), (int)psize.getHeight());
}
+
+ if ( getContainer()!=null && styleSheet.title!=null && styleSheet.titleWidth==-1 )
+ {
+ FontMetrics metrics = g.getFontMetrics(styleSheet.titleFont);
+ styleSheet.titleWidth = metrics.stringWidth(styleSheet.title);
+ styleSheet.titleHeight = metrics.getHeight();
+ }
}
***************
*** 467,487 ****
//-------------------------------------------------------------------------
public int viewToModel(float x, float y, Shape a)
! { return nested.viewToModel(x,y, a); }
public int viewToModel(float x, float y, Shape a, Position.Bias[] biasReturn)
! { return nested.viewToModel(x,y,a,biasReturn); }
public Shape modelToView(int p0, Position.Bias b0, int p1, Position.Bias b1, Shape a)
throws BadLocationException
! { return nested.modelToView(p0,b0,p1,b1,a); }
public Shape modelToView(int pos, Shape a)
throws BadLocationException
! { return nested.modelToView(pos,a); }
public Shape modelToView(int pos, Shape a, Position.Bias b)
throws BadLocationException
! { return nested.modelToView(pos,a,b); }
//-------------------------------------------------------------------------
--- 479,544 ----
//-------------------------------------------------------------------------
+ /**
+ * Transforms the given shape that corresponds to the container view to
+ * the destination view.
+ */
+ public static Shape translateNestedToView(Shape shape, Styleable.StyleSheet styleSheet)
+ {
+ Rectangle2D bounds = (Rectangle2D)shape.getBounds();
+ double x = bounds.getX()+getLeftInset(styleSheet);
+ double y = bounds.getY()+getTopInset(styleSheet);
+ double w = bounds.getWidth();
+ double h = bounds.getHeight();
+ bounds.setRect(x,y,w,h);
+ return bounds;
+ }
+
+ /**
+ * Transforms the given shape that corresponds to the container view to
+ * the destination view.
+ */
+ public static Shape translateViewToNested(Shape shape, Styleable.StyleSheet styleSheet)
+ {
+ Rectangle2D bounds = (Rectangle2D)shape.getBounds();
+ double x = bounds.getX()-getLeftInset(styleSheet);
+ double y = bounds.getY()-getTopInset(styleSheet);
+ double w = bounds.getWidth();
+ double h = bounds.getHeight();
+ bounds.setRect(x,y,w,h);
+ return bounds;
+ }
+
public int viewToModel(float x, float y, Shape a)
! {
! return nested.viewToModel(x-getLeftInset(styleSheet),
! y-getTopInset(styleSheet),a);
! }
public int viewToModel(float x, float y, Shape a, Position.Bias[] biasReturn)
! {
! return nested.viewToModel(x-getLeftInset(styleSheet),
! y-getTopInset(styleSheet),a,biasReturn);
! }
public Shape modelToView(int p0, Position.Bias b0, int p1, Position.Bias b1, Shape a)
throws BadLocationException
! {
! Rectangle2D shape = (Rectangle2D) nested.modelToView(p0,b0,p1,b1,a);
! return translateNestedToView(shape, styleSheet);
! }
public Shape modelToView(int pos, Shape a)
throws BadLocationException
! {
! Rectangle2D shape = (Rectangle2D) nested.modelToView(pos,a);
! return translateNestedToView(shape, styleSheet);
! }
public Shape modelToView(int pos, Shape a, Position.Bias b)
throws BadLocationException
! {
! Rectangle2D shape = (Rectangle2D) nested.modelToView(pos,a,b);
! return translateNestedToView(shape, styleSheet);
! }
//-------------------------------------------------------------------------
***************
*** 493,524 ****
public float getPreferredSpan(int axis)
{
//We check wether the wrapper view is collapsed or not
if (!collapsed)
{
! if (axis==View.X_AXIS)
! {
! if ( attributesDisplay!=null )
! {
! float span = (float)nested.getPreferredSpan(axis);
! return Math.max(span,
! (float)attributesDisplay.getPreferredSize().getWidth());
! }
! else
! {
! return nested.getPreferredSpan(axis);
! }
! }
! else
! {
! if ( attributesDisplay!=null )
! {
! float span = (float)nested.getPreferredSpan(axis);
! return Math.max(span,
! (float)attributesDisplay.getPreferredSize().getHeight());
! }
! else
! {
! return nested.getPreferredSpan(axis);
! }
}
}
--- 550,563 ----
public float getPreferredSpan(int axis)
{
+ float result;
//We check wether the wrapper view is collapsed or not
if (!collapsed)
{
! result = (float)nested.getPreferredSpan(axis);
! if (styleSheet.attributesDisplay!=null)
! {
! Dimension size = styleSheet.attributesDisplay.getPreferredSize();
! if (axis==View.X_AXIS) { result=Math.max(result,(float)size.getWidth()); }
! else { result=Math.max(result,(float)size.getHeight()); }
}
}
***************
*** 527,566 ****
{
if (axis==View.X_AXIS)
! { return nested.getPreferredSpan(axis); }
else
! { return Math.max(10,styleSheet.paddingTop+styleSheet.paddingBottom); }
}
}
public float getMinimumSpan(int axis)
{
//We check wether the wrapper view is collapsed or not
if (!collapsed)
{
! if (axis==View.X_AXIS)
! {
! if ( attributesDisplay!=null )
! {
! float span = (float)nested.getMinimumSpan(axis);
! return Math.max(span,
! (float)attributesDisplay.getMinimumSize().getWidth());
! }
! else
! {
! return nested.getMinimumSpan(axis);
! }
! }
! else
! {
! if ( attributesDisplay!=null )
! {
! float span = (float)nested.getMinimumSpan(axis);
! return Math.max(span,
! (float)attributesDisplay.getMinimumSize().getHeight());
! }
! else
! {
! return nested.getMinimumSpan(axis);
! }
}
}
--- 566,589 ----
{
if (axis==View.X_AXIS)
! { result = nested.getPreferredSpan(axis); }
else
! { result = styleSheet.paddingTop+styleSheet.paddingBottom; }
}
+ //We make sure the view is not less than 10x10 pixels.
+ return Math.max(MIN_HEIGHT,result);
}
public float getMinimumSpan(int axis)
{
+ float result;
//We check wether the wrapper view is collapsed or not
if (!collapsed)
{
! result = (float)nested.getMinimumSpan(axis);
! if (styleSheet.attributesDisplay!=null)
! {
! Dimension size = styleSheet.attributesDisplay.getPreferredSize();
! if (axis==View.X_AXIS) { result=Math.max(result,(float)size.getWidth()); }
! else { result=Math.max(result,(float)size.getHeight()); }
}
}
***************
*** 569,611 ****
{
if (axis==View.X_AXIS)
! { return nested.getMinimumSpan(axis); }
else
! { return Math.max(10,styleSheet.paddingTop+styleSheet.paddingBottom); }
}
}
public float getMaximumSpan(int axis)
{
! if ( getStartOffset()>=getEndOffset()-1 )
! { return 10; }
!
//We check wether the wrapper view is collapsed or not
if (!collapsed)
{
! if (axis==View.X_AXIS)
! {
! if ( attributesDisplay!=null )
! {
! float span = (float)nested.getMaximumSpan(axis);
! return Math.max(span,
! (float)attributesDisplay.getMaximumSize().getWidth());
! }
! else
! {
! return nested.getMaximumSpan(axis);
! }
! }
! else
! {
! if ( attributesDisplay!=null )
! {
! float span = (float)nested.getMaximumSpan(axis);
! return Math.max(span,
! (float)attributesDisplay.getMaximumSize().getHeight());
! }
! else
! {
! return nested.getMaximumSpan(axis);
! }
}
}
--- 592,615 ----
{
if (axis==View.X_AXIS)
! { result = nested.getMinimumSpan(axis); }
else
! { result = styleSheet.paddingTop+styleSheet.paddingBottom; }
}
+ //We make sure the view is not less than 10x10 pixels.
+ return Math.max(MIN_HEIGHT,result);
}
public float getMaximumSpan(int axis)
{
! float result;
//We check wether the wrapper view is collapsed or not
if (!collapsed)
{
! result = (float)nested.getMaximumSpan(axis);
! if (styleSheet.attributesDisplay!=null)
! {
! Dimension size = styleSheet.attributesDisplay.getPreferredSize();
! if (axis==View.X_AXIS) { result=Math.max(result,(float)size.getWidth()); }
! else { result=Math.max(result,(float)size.getHeight()); }
}
}
***************
*** 614,621 ****
{
if (axis==View.X_AXIS)
! { return nested.getMaximumSpan(axis); }
else
! { return Math.max(15,styleSheet.paddingTop+styleSheet.paddingBottom); }
}
}
--- 618,627 ----
{
if (axis==View.X_AXIS)
! { result = nested.getMaximumSpan(axis); }
else
! { result = styleSheet.paddingTop+styleSheet.paddingBottom; }
}
+ //We make sure the view is not less than 10x10 pixels.
+ return Math.max(MIN_HEIGHT,result);
}
***************
*** 625,628 ****
--- 631,750 ----
//-------------------------------------------------------------------------
//
+ // Insets management
+ //
+ //-------------------------------------------------------------------------
+
+ /**
+ * This is a utility method that computes the insets of a given nested
+ * view according to the information found in the given StyleSheet.
+ * Any view that wants to be displayed correctly should use the values
+ * returned by this method.
+ * @param the stylesheet that contains the inset information.
+ * @return the left inset of this view as a short.
+ * @see #getRightInset
+ * @see #getTopInset
+ * @see #getBottomInset
+ */
+ public static short getLeftInset(Styleable.StyleSheet styleSheet)
+ {
+ //In case the view sticks to the title
+ if ( styleSheet.contentStick==Styleable.StyleSheet.TITLE_UL
+ || styleSheet.contentStick==Styleable.StyleSheet.TITLE_LL)
+ {
+ return (short)(styleSheet.titlePaddingLeft + styleSheet.paddingLeft);
+ }
+ else if ( styleSheet.contentStick==Styleable.StyleSheet.TITLE_UR
+ || styleSheet.contentStick==Styleable.StyleSheet.TITLE_LR )
+ {
+ return (short)(styleSheet.titlePaddingLeft + styleSheet.titleWidth+
+ styleSheet.titlePaddingBottom+styleSheet.paddingLeft);
+ }
+ //In case the view sticks to the attributes
+ else if ( styleSheet.attributesDisplay!=null &&
+ styleSheet.contentStick==Styleable.StyleSheet.ATTR_UL
+ || styleSheet.contentStick==Styleable.StyleSheet.ATTR_LL)
+ {
+ return (short)(styleSheet.attributesPaddingLeft + styleSheet.paddingLeft);
+ }
+ else if ( styleSheet.attributesDisplay!=null &&
+ styleSheet.contentStick==Styleable.StyleSheet.ATTR_UR
+ || styleSheet.contentStick==Styleable.StyleSheet.ATTR_LR )
+ {
+ return (short)(styleSheet.attributesPaddingLeft +
+ styleSheet.attributesDisplay.getPreferredSize().getHeight()+
+ styleSheet.attributesPaddingBottom+styleSheet.paddingLeft);
+ }
+ //Otherwise is does stick to the upper left corner of the view
+ else
+ { return styleSheet.paddingLeft; }
+ }
+
+ /**
+ * This is a utility method that computes the insets of a given nested
+ * view according to the information found in the given StyleSheet.
+ * Any view that wants to be displayed correctly should use the values
+ * returned by this method.
+ * @param the stylesheet that contains the inset information.
+ * @return the top inset of this view as a short.
+ * @see #getRightInset
+ * @see #getLeftInset
+ * @see #getBottomInset
+ */
+ public static short getTopInset(Styleable.StyleSheet styleSheet)
+ {
+ //In case the view sticks to a title
+ if ( styleSheet.contentStick==Styleable.StyleSheet.TITLE_LL
+ || styleSheet.contentStick==Styleable.StyleSheet.TITLE_LR )
+ {
+ return (short)(styleSheet.titlePaddingTop+styleSheet.titleHeight+
+ styleSheet.titlePaddingBottom+styleSheet.paddingTop);
+ }
+ //In case the view sticks to the attirutes
+ else if ( styleSheet.attributesDisplay!=null &&
+ styleSheet.contentStick==Styleable.StyleSheet.ATTR_LL
+ || styleSheet.contentStick==Styleable.StyleSheet.ATTR_LR )
+ {
+ return (short)(styleSheet.attributesPaddingTop+
+ styleSheet.attributesDisplay.getSize().getHeight()+
+ styleSheet.attributesPaddingBottom+styleSheet.paddingTop);
+ }
+ //Otherwise it sticks to the origin
+ else
+ {
+ return styleSheet.paddingTop;
+ }
+ }
+
+ /**
+ * This is a utility method that computes the insets of a given nested
+ * view according to the information found in the given StyleSheet.
+ * Any view that wants to be displayed correctly should use the values
+ * returned by this method.
+ * @param the stylesheet that contains the inset information.
+ * @return the bottom inset of this view as a short.
+ * @see #getRightInset
+ * @see #getLeftInset
+ * @see #getTopInset
+ */
+ public static short getBottomInset(Styleable.StyleSheet styleSheet)
+ { return styleSheet.paddingBottom; }
+
+ /**
+ * This is a utility method that computes the insets of a given nested
+ * view according to the information found in the given StyleSheet.
+ * Any view that wants to be displayed correctly should use the values
+ * returned by this method.
+ * @param the stylesheet that contains the inset information.
+ * @return the right inset of this view as a short.
+ * @see #getBottomInset
+ * @see #getLeftInset
+ * @see #getTopInset
+ */
+ public static short getRightInset(Styleable.StyleSheet styleSheet)
+ { return styleSheet.paddingRight; }
+
+
+ //-------------------------------------------------------------------------
+ //
// View management
//
***************
*** 645,648 ****
--- 767,779 ----
{ nested.replace(offset,length,views); }
+ /**
+ * <p>The <code>setParent</code> method plays quite a big role in the
+ * WrapperView. Is is strangely called very often by the Swing text
+ * display enginge (JTextComponent), in this respect this method has
+ * to be very fast.</p>
+ * <p>This basically creates the nested view and the attributes display
+ * if it has to. Most of the processing here is only done once, during
+ * the first binding of the <code>WrapperView</code>.
+ */
public void setParent(View parent)
{
***************
*** 666,676 ****
//This automatically updates the nested view stylesheet
if ( hasToUpdate )
! { setStyleSheet(styleSheet); hasToUpdate=false;}
if ( parent!=nested.getParent() )
! { nested.setParent(parent);}
! //if ( attributes!=null )
! //{ attributes.setParent(parent); attributes.getComponent().setSize(40,10); }
}
--- 797,858 ----
//This automatically updates the nested view stylesheet
if ( hasToUpdate )
! {
! setStyleSheet(styleSheet);
! hasToUpdate=false;
! }
if ( parent!=nested.getParent() )
! {
! nested.setParent(parent);
! }
! //XMLElementWrapper is the only one that has attributes
! if ( styleSheet.attributesDisplay==null && element instanceof XMLElementWrapper )
! {
!
! if ( ((XMLElementWrapper)element).getXMLElement().getAttributes().size()>0 )
! {
! Object style = styleSheet.getStyle("attributes.display");
! XMLElementWrapper wrapper = (XMLElementWrapper)element;
! if ( style!=null )
! {
! //We use reflection to create a new instance of the AttributesDisplay
! //subclass given by the <attributes.display> property.
! try
! {
! Class display = Class.forName(style.toString());
! Constructor constructor =
! display.getConstructor(new Class[] { XMLElementWrapper.class, WrapperView.class });
! styleSheet.attributesDisplay = (AttributesDisplay)constructor.newInstance(
! new Object[] { wrapper, this });
! }
! catch (Exception e)
! {
! //If the class has not been found in the Java environemnt, then we try to
! //load it from the python environment.
! Application.python.set("wrapper", wrapper);
! Application.python.set("view", this);
! Application.python.exec("new_instance = getInstance('"+style.toString()
! +"', (wrapper, view))");
! try
! {
! styleSheet.attributesDisplay =
! (AttributesDisplay)Application.python.get("new_instance", AttributesDisplay.class);
! }
! catch (NullPointerException ex)
! { System.err.println(ex); }
!
! if ( styleSheet.attributesDisplay == null )
! {
! System.err.println("Class <"+style.toString()+"> has not been found.");
! System.err.println(" -->"+e.toString());
! styleSheet.attributesDisplay = new AttributesDisplay(wrapper,this);
! }
! }
! }
! else
! { styleSheet.attributesDisplay = new AttributesDisplay(wrapper,this); }
! }
! }
}
***************
*** 772,776 ****
//-------------------------------------------------------------------------
//
! // StyleSheet
//
//-------------------------------------------------------------------------
--- 954,958 ----
//-------------------------------------------------------------------------
//
! // StyleSheet management
//
//-------------------------------------------------------------------------
***************
*** 789,792 ****
--- 971,976 ----
s.update();
}
+ if ( styleSheet.attributesDisplay!=null )
+ { styleSheet.attributesDisplay.setFont(s.font); }
}
***************
*** 826,853 ****
}
}
-
- public class Constrainer extends javax.swing.text.ComponentView
- {
-
- public Constrainer(Element e)
- {
- super(e);
- }
-
- public float getMaximumSpan()
- {
- return 50.0f;
- }
- public float getMinimumSpan()
- {
- return 50.0f;
- }
- public float getPreferredSpan()
- {
- return 50.0f;
- }
- }
-
-
}
// EOF-Unix/ASCII-------------------------------------@RisingSun//Java//1.0//EN
--- 1010,1013 ----
--- TableView.java DELETED ---
|