Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Toolbarproblem
Toolbarproblem [message #244533] Thu, 24 July 2008 06:37
Andreas  is currently offline Andreas Friend
Messages: 29
Registered: July 2009
Junior Member
Hi everybody,

i'm new to gef and draw2d. I try to create an layout which look like a
table definition. i have a table with lots of columns. my problem is, that
i want to create an column (out of the palette), i can't do this because
the figure diallow this when i use the xylayout for the table and
toolbarlayout for the column i can do this. but i look like ..... i want
to display the columns like in the uml diagramm.

do anyone have an idea how to do this?


Thanks for your help...

it's a little hard to explain, but here are the two sources of the figures

TABLE_FIGURE:

package com.proalpha.java.oea.plugin.padesigner.figure;

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.LineBorder;
import org.eclipse.draw2d.ToolbarLayout;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.graphics.Color;

public class TableFigure extends Figure {

private Label labelName = new Label();
private Label labelDomain = new Label();
public static Color classColor = new Color(null, 255, 255, 206);
private ColumnFigure attributeFigure = new ColumnFigure();
public static final int SERVICE_FIGURE_DEFHEIGHT = 150;
public static final int SERVICE_FIGURE_DEFWIDTH = 250;

public TableFigure(Label name,Label domain) {
/*
* XYLayout layout = new XYLayout(); setLayoutManager(layout);
*
* labelName.setForegroundColor(ColorConstants.darkGray); add(labelName,
* ToolbarLayout.ALIGN_CENTER); setConstraint(labelName, new
* Rectangle(5, 17, -1, -1));
*
* labelDomain.setForegroundColor(ColorConstants.black);
* add(labelDomain, ToolbarLayout.ALIGN_CENTER);
* setConstraint(labelDomain, new Rectangle(5, 5, -1, -1));
*
* setForegroundColor(ColorConstants.black);
*
* setBorder(new LineBorder(1)); setOpaque(true);
*/

labelName = name;
ToolbarLayout layout = new ToolbarLayout();
setLayoutManager(layout);
setBorder(new LineBorder(ColorConstants.black, 1));
setBackgroundColor(classColor);
setOpaque(true);

add(labelName);
add(labelDomain);
add(attributeFigure);

}

public ColumnFigure getAttributesColumn()
{
return attributeFigure;
}
public void setName(String text) {
labelName.setText(text);
}

public void setDomain(String domain) {
labelDomain.setText(domain);
}

public void setLayout(Rectangle rect) {
getParent().setConstraint(this, rect);
}
}


COLUMN_FIGURE:

package com.proalpha.java.oea.plugin.padesigner.figure;

import org.eclipse.draw2d.AbstractBorder;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.LineBorder;
import org.eclipse.draw2d.ToolbarLayout;
import org.eclipse.draw2d.geometry.Insets;
import org.eclipse.draw2d.geometry.Rectangle;

public class ColumnFigure extends Figure {

private Label labelColumn = new Label();

public static final int EMPLOYE_FIGURE_DEFHEIGHT = 40;
public static final int EMPLOYE_FIGURE_DEFWIDTH = 60;

public ColumnFigure() {
ToolbarLayout layout = new ToolbarLayout();
layout.setMinorAlignment(ToolbarLayout.ALIGN_TOPLEFT);
layout.setStretchMinorAxis(false);
layout.setSpacing(2);
setLayoutManager(layout);
setBorder(new CompartmentFigureBorder());
}

public class CompartmentFigureBorder extends AbstractBorder {
public Insets getInsets(IFigure figure) {
return new Insets(1, 0, 0, 0);
}

public void paint(IFigure figure, Graphics graphics, Insets insets) {
graphics.drawLine(getPaintRectangle(figure, insets).getTopLeft(),
tempRect.getTopRight());
}
}

public void setColumnText(String text) {
labelColumn.setText(text);
}

public void setLayout(Rectangle rect) {
getParent().setConstraint(this, rect);
}
}
Previous Topic:ZEST: Clustering or nesting algorithms
Next Topic:Router problem
Goto Forum:
  


Current Time: Fri Apr 19 00:38:53 GMT 2024

Powered by FUDForum. Page generated in 0.01987 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top