Commit 498b6b0b authored by Guillaume Chomat's avatar Guillaume Chomat
Browse files

corrected the port preview renderer

parent bf7d627e
......@@ -25,38 +25,55 @@ public class FCPortRenderer extends PortRenderer {
super();
}
/**
* Paint the renderer. Overrides superclass paint
* to add specific painting.
*/
public void paint(Graphics g) {
public void paint ( Graphics g )
{
Dimension d = getSize();
g.setColor(graph.getBackground());
//g.setXORMode(graph.getBackground());
if (preview) {
System.out.println("preview");
g.setColor(getBackground());
//g.setColor(Color.red);
g.drawRect(1, 1, d.width-3, d.height-3);
g.drawRect(2, 2, d.width-5, d.height-5);
}
boolean offset = (GraphConstants.getOffset(view.getAttributes()) != null);
g.setColor(getForeground());
if (offset) {
System.out.println("offset");
g.drawRect(1, 1, d.width-3,d.height-3);
g.setColor(getBackground());
g.drawRect(2, 2, d.width-5, d.height-5);
} else if (!preview)
g.setClip(0, 0, d.width + 1, d.height + 1);
if (preview)
paintPreview(g, d);
else
paintPort(g, d);
}
protected void paintPreview(Graphics g, Dimension d )
{
Map attr = view.getAttributes();
int offset = ( GraphConstants.getOffset(attr) != null ) ? 0 : 1;
g.setXORMode(graph.getBackground());
g.setColor(getBackground());
g.drawRect(0, 0, d.width - offset, d.height - offset);
g.drawRect(1, 1, d.width - 2 - offset, d.height - 2 - offset);
g.drawRect(2, 2, d.width - 4 - offset, d.height - 4 - offset);
}
protected void paintPort ( Graphics g, Dimension d )
{
Map attr = view.getAttributes();
Color backCol = GraphConstants.getBackground(attr);
Color foreCol = GraphConstants.getForeground(attr);
g.setPaintMode();
if ( foreCol != null )
g.setColor(foreCol);
else
g.setColor(getForeground());
g.drawRect(0, 0, d.width, d.height);
if ( backCol != null )
{
System.out.println("not preview");
// g.setColor(Color.red);
g.drawRect(2, 2, d.width-3, d.height-3);
g.setColor(getBackground());
g.drawRect(2, 2, d.width-5, d.height-5);
g.setColor(backCol);
g.fillRect(1, 1, d.width - 1, d.height - 1);
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment