use of org.eclipse.draw2d.geometry.Rectangle in project cogtool by cogtool.
the class PERTInteractivePanel method resizeVisualization.
@Override
public void resizeVisualization(Event e) {
int regionWidth = getClientArea().width - (marginLeft + marginRight);
if (regionWidth > 0) {
double displayedTime = displayEndTime - displayStartTime;
// find appropriate resolution for timeline
dispTimeInterval = 1;
int x = 1;
while ((regionWidth * ((dispTimeInterval) / displayedTime)) < 4.0) {
dispTimeInterval = Math.pow(10, x);
x++;
}
dispTimeIntervalWidth = (regionWidth) * (dispTimeInterval / displayedTime);
int timeLineX = marginLeft - (int) ((displayStartTime / displayedTime) * regionWidth);
int hiddenWidth = (int) (regionWidth * (totalTime / displayedTime));
timeLine.setBounds(new Rectangle(timeLineX, 0, hiddenWidth, marginTop));
}
super.resizeVisualization(e);
}
use of org.eclipse.draw2d.geometry.Rectangle in project cogtool by cogtool.
the class PERTPanel method resizeVisualization.
/**
* Resets the position and size of the PERTChartOperatorBar objects
* when the panel is resized.
*
* @param e resize Event to respond to.
*/
public void resizeVisualization(Event e) {
int totalWidth = getVisualizationWidth();
int totalHeight = getVisualizationHeight();
int regionHeight = PrecisionUtilities.round((totalHeight - 10) / Math.max(numRows, 1));
Iterator<PERTChartOperatorBar> barIterator = bars.iterator();
PERTChartOperatorBar bar;
int barW;
int barH;
int barX;
int barY;
// rescale the width of each bar based on the ratio of it's duration to
// the total time, and set its new position
double displayedDuration = displayEndTime - displayStartTime;
if ((totalTime > 0) && (displayedDuration > 0)) {
while (barIterator.hasNext()) {
bar = barIterator.next();
// Calculate position based on the position of the right of the
// bar to avoid oscillating widths
int barRightPos = marginLeft + PrecisionUtilities.round(((bar.getStartTime() + bar.getDuration() - displayStartTime) / displayedDuration) * (totalWidth - 10));
//
// barW = PrecisionUtilities.round((bar.getDuration() * (totalWidth - 10))
// / displayedDuration) + 1;
barX = marginLeft + PrecisionUtilities.round(((bar.getStartTime() - displayStartTime) / displayedDuration) * (totalWidth - 10));
barW = barRightPos - barX + 1;
if (bar.isCascade()) {
int y1 = Math.min(bar.getRow(), bar.getEndRow());
int y2 = Math.max(bar.getRow(), bar.getEndRow());
barY = marginTop + (y1 * regionHeight) + PrecisionUtilities.round(0.5 * barHeight);
barH = (y2 - y1) * regionHeight;
if (barW < 1) {
barW = 1;
}
} else {
barY = marginTop + (bar.getRow() * regionHeight);
barH = barHeight;
if (barW < 3) {
barX -= 1;
barW = 3;
}
}
bar.setBounds(new Rectangle(barX, barY, barW, barH));
}
}
lws.getUpdateManager().performUpdate();
}
use of org.eclipse.draw2d.geometry.Rectangle in project dbeaver by serge-rider.
the class DiagramPart method setTableModelBounds.
/**
* Updates the table bounds in the model so that the same bounds can be
* restored after saving
*
* @return whether the procedure execute successfully without any omissions.
* The latter occurs if any EntityFigure has no bounds set for any of
* the Table model objects
*/
public boolean setTableModelBounds() {
List<?> entityParts = getChildren();
for (Iterator<?> iter = entityParts.iterator(); iter.hasNext(); ) {
NodePart entityPart = (NodePart) iter.next();
IFigure entityFigure = entityPart.getFigure();
// continue
if (entityFigure == null) {
continue;
}
Rectangle bounds = entityFigure.getBounds().getCopy();
entityPart.setBounds(bounds);
}
return true;
}
use of org.eclipse.draw2d.geometry.Rectangle in project dbeaver by serge-rider.
the class DiagramXYLayoutPolicy method getCurrentConstraintFor.
/**
* Returns the current bounds as the constraint if none can be found in the
* figures Constraint object
*/
@Override
public Rectangle getCurrentConstraintFor(GraphicalEditPart child) {
IFigure fig = child.getFigure();
Rectangle rectangle = (Rectangle) fig.getParent().getLayoutManager().getConstraint(fig);
if (rectangle == null) {
rectangle = fig.getBounds();
}
return rectangle;
}
use of org.eclipse.draw2d.geometry.Rectangle in project dbeaver by serge-rider.
the class EntityPart method createFigure.
//******************* Layout related methods *********************/
/**
* Creates a figure which represents the table
*/
@Override
protected EntityFigure createFigure() {
final EntityFigure figure = new EntityFigure(getTable());
final EntityDiagram diagram = ((DiagramPart) getParent()).getDiagram();
Rectangle bounds = diagram.getInitBounds(getTable());
if (bounds != null) {
figure.setLocation(bounds.getLocation());
}
return figure;
}
Aggregations