use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class JobPainter method drawJob.
public void drawJob() {
Point max = jobMeta.getMaximum();
Point thumb = getThumb(area, max);
offset = getOffset(thumb, area);
gc.setBackground(EColor.BACKGROUND);
if (hori != null) {
hori.setThumb(thumb.x);
}
if (vert != null) {
vert.setThumb(thumb.y);
}
//
if (shadowSize > 0) {
gc.setAlpha(20);
gc.setTransform(translationX, translationY, shadowSize, magnification);
shadow = true;
drawJobElements();
}
// Draw the transformation onto the image
//
gc.setAlpha(255);
gc.setTransform(translationX, translationY, 0, magnification);
shadow = false;
drawJobElements();
gc.dispose();
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class JobPainter method drawJobEntryCopy.
protected void drawJobEntryCopy(JobEntryCopy jobEntryCopy) {
if (!jobEntryCopy.isDrawn()) {
return;
}
int alpha = gc.getAlpha();
Point pt = jobEntryCopy.getLocation();
if (pt == null) {
pt = new Point(50, 50);
}
Point screen = real2screen(pt.x, pt.y);
int x = screen.x;
int y = screen.y;
String name = jobEntryCopy.getName();
if (jobEntryCopy.isSelected()) {
gc.setLineWidth(3);
} else {
gc.setLineWidth(1);
}
gc.setBackground(EColor.BACKGROUND);
gc.fillRoundRectangle(x - 1, y - 1, iconsize + 1, iconsize + 1, 7, 7);
gc.drawJobEntryIcon(x, y, jobEntryCopy, magnification);
if (!shadow) {
areaOwners.add(new AreaOwner(AreaType.JOB_ENTRY_ICON, x, y, iconsize, iconsize, offset, subject, jobEntryCopy));
}
gc.setForeground(jobEntryCopy.isMissing() ? EColor.RED : EColor.CRYSTAL);
gc.drawRoundRectangle(x - 1, y - 1, iconsize + 1, iconsize + 1, 7, 7);
gc.setForeground(EColor.CRYSTAL);
Point textsize = new Point(gc.textExtent("" + name).x, gc.textExtent("" + name).y);
gc.setBackground(EColor.BACKGROUND);
gc.setLineWidth(1);
int xpos = x + (iconsize / 2) - (textsize.x / 2);
int ypos = y + iconsize + 5;
gc.setForeground(EColor.BLACK);
gc.drawText(name, xpos, ypos, true);
if (activeJobEntries != null && activeJobEntries.contains(jobEntryCopy)) {
gc.setForeground(EColor.BLUE);
int iconX = (x + iconsize) - (MINI_ICON_SIZE / 2);
int iconY = y - (MINI_ICON_SIZE / 2);
gc.drawImage(EImage.BUSY, iconX, iconY, magnification);
areaOwners.add(new AreaOwner(AreaType.JOB_ENTRY_BUSY, iconX, iconY, MINI_ICON_SIZE, MINI_ICON_SIZE, offset, subject, jobEntryCopy));
} else {
gc.setForeground(EColor.BLACK);
}
JobEntryResult jobEntryResult = findJobEntryResult(jobEntryCopy);
if (jobEntryResult != null) {
Result result = jobEntryResult.getResult();
int iconX = (x + iconsize) - (MINI_ICON_SIZE / 2);
int iconY = y - (MINI_ICON_SIZE / 2);
//
if (jobEntryResult.isCheckpoint()) {
gc.drawImage(EImage.CHECKPOINT, iconX, iconY, magnification);
areaOwners.add(new AreaOwner(AreaType.JOB_ENTRY_RESULT_CHECKPOINT, iconX, iconY, MINI_ICON_SIZE, MINI_ICON_SIZE, offset, jobEntryCopy, jobEntryResult));
} else {
if (result.getResult()) {
gc.drawImage(EImage.TRUE, iconX, iconY, magnification);
areaOwners.add(new AreaOwner(AreaType.JOB_ENTRY_RESULT_SUCCESS, iconX, iconY, MINI_ICON_SIZE, MINI_ICON_SIZE, offset, jobEntryCopy, jobEntryResult));
} else {
gc.drawImage(EImage.FALSE, iconX, iconY, magnification);
areaOwners.add(new AreaOwner(AreaType.JOB_ENTRY_RESULT_FAILURE, iconX, iconY, MINI_ICON_SIZE, MINI_ICON_SIZE, offset, jobEntryCopy, jobEntryResult));
}
}
}
//
if (mouseOverEntries.contains(jobEntryCopy)) {
gc.setTransform(translationX, translationY, 0, BasePainter.FACTOR_1_TO_1);
EImage[] miniIcons = new EImage[] { EImage.INPUT, EImage.EDIT, EImage.CONTEXT_MENU, EImage.OUTPUT };
// First drawn the mini-icons balloon below the job entry
//
int totalHeight = 0;
int totalIconsWidth = 0;
int totalWidth = 2 * MINI_ICON_MARGIN;
for (EImage miniIcon : miniIcons) {
Point bounds = gc.getImageBounds(miniIcon);
totalWidth += bounds.x + MINI_ICON_MARGIN;
totalIconsWidth += bounds.x + MINI_ICON_MARGIN;
if (bounds.y > totalHeight) {
totalHeight = bounds.y;
}
}
totalHeight += 2 * MINI_ICON_MARGIN;
gc.setFont(EFont.SMALL);
String trimmedName = jobEntryCopy.getName().length() < 30 ? jobEntryCopy.getName() : jobEntryCopy.getName().substring(0, 30);
Point nameExtent = gc.textExtent(trimmedName);
nameExtent.y += 2 * MINI_ICON_MARGIN;
nameExtent.x += 3 * MINI_ICON_MARGIN;
totalHeight += nameExtent.y;
if (nameExtent.x > totalWidth) {
totalWidth = nameExtent.x;
}
int areaX = translateToCurrentScale(x) + translateToCurrentScale(iconsize) / 2 - totalWidth / 2 + MINI_ICON_SKEW;
int areaY = translateToCurrentScale(y) + translateToCurrentScale(iconsize) + MINI_ICON_DISTANCE + BasePainter.CONTENT_MENU_INDENT;
gc.setForeground(EColor.CRYSTAL);
gc.setBackground(EColor.CRYSTAL);
gc.setLineWidth(1);
gc.fillRoundRectangle(areaX, areaY, totalWidth, totalHeight, BasePainter.CORNER_RADIUS_5, BasePainter.CORNER_RADIUS_5);
gc.setBackground(EColor.WHITE);
gc.fillRoundRectangle(areaX, areaY + nameExtent.y, totalWidth, (totalHeight - nameExtent.y), BasePainter.CORNER_RADIUS_5, BasePainter.CORNER_RADIUS_5);
gc.fillRectangle(areaX, areaY + nameExtent.y, totalWidth, (totalHeight - nameExtent.y) / 2);
gc.drawRoundRectangle(areaX, areaY, totalWidth, totalHeight, BasePainter.CORNER_RADIUS_5, BasePainter.CORNER_RADIUS_5);
gc.setForeground(EColor.WHITE);
gc.drawText(trimmedName, areaX + (totalWidth - nameExtent.x) / 2 + MINI_ICON_MARGIN, areaY + MINI_ICON_MARGIN, true);
gc.setForeground(EColor.CRYSTAL);
gc.setBackground(EColor.CRYSTAL);
gc.setFont(EFont.GRAPH);
areaOwners.add(new AreaOwner(AreaType.MINI_ICONS_BALLOON, translateTo1To1(areaX), translateTo1To1(areaY), translateTo1To1(totalWidth), translateTo1To1(totalHeight), offset, jobMeta, jobEntryCopy));
gc.fillPolygon(new int[] { areaX + totalWidth / 2 - MINI_ICON_TRIANGLE_BASE / 2 + 1, areaY + 2, areaX + totalWidth / 2 + MINI_ICON_TRIANGLE_BASE / 2, areaY + 2, areaX + totalWidth / 2 - MINI_ICON_SKEW, areaY - MINI_ICON_DISTANCE - 3 });
gc.setBackground(EColor.WHITE);
// Put on the icons...
//
int xIcon = areaX + (totalWidth - totalIconsWidth) / 2 + MINI_ICON_MARGIN;
int yIcon = areaY + 5 + nameExtent.y;
for (int i = 0; i < miniIcons.length; i++) {
EImage miniIcon = miniIcons[i];
Point bounds = gc.getImageBounds(miniIcon);
boolean enabled = false;
switch(i) {
case // INPUT
0:
enabled = !jobEntryCopy.isStart();
areaOwners.add(new AreaOwner(AreaType.JOB_ENTRY_MINI_ICON_INPUT, translateTo1To1(xIcon), translateTo1To1(yIcon), translateTo1To1(bounds.x), translateTo1To1(bounds.y), offset, jobMeta, jobEntryCopy));
break;
case // EDIT
1:
enabled = true;
areaOwners.add(new AreaOwner(AreaType.JOB_ENTRY_MINI_ICON_EDIT, translateTo1To1(xIcon), translateTo1To1(yIcon), translateTo1To1(bounds.x), translateTo1To1(bounds.y), offset, jobMeta, jobEntryCopy));
break;
case // Job entry context menu
2:
enabled = true;
areaOwners.add(new AreaOwner(AreaType.JOB_ENTRY_MINI_ICON_CONTEXT, translateTo1To1(xIcon), translateTo1To1(yIcon), translateTo1To1(bounds.x), translateTo1To1(bounds.y), offset, jobMeta, jobEntryCopy));
break;
case // OUTPUT
3:
enabled = true;
areaOwners.add(new AreaOwner(AreaType.JOB_ENTRY_MINI_ICON_OUTPUT, translateTo1To1(xIcon), translateTo1To1(yIcon), translateTo1To1(bounds.x), translateTo1To1(bounds.y), offset, jobMeta, jobEntryCopy));
break;
default:
break;
}
if (enabled) {
gc.setAlpha(255);
} else {
gc.setAlpha(100);
}
gc.drawImage(miniIcon, xIcon, yIcon, BasePainter.FACTOR_1_TO_1);
xIcon += bounds.x + 5;
}
gc.setTransform(translationX, translationY, 0, magnification);
}
// Restore the previous alpha value
//
gc.setAlpha(alpha);
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class JobPainter method drawJobElements.
private void drawJobElements() {
if (!shadow && gridSize > 1) {
drawGrid();
}
try {
ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.JobPainterStart.id, this);
} catch (KettleException e) {
LogChannel.GENERAL.logError("Error in JobPainterStart extension point", e);
}
// First draw the notes...
gc.setFont(EFont.NOTE);
for (int i = 0; i < jobMeta.nrNotes(); i++) {
NotePadMeta ni = jobMeta.getNote(i);
drawNote(ni);
}
gc.setFont(EFont.GRAPH);
// ... and then the rest on top of it...
for (int i = 0; i < jobMeta.nrJobHops(); i++) {
JobHopMeta hi = jobMeta.getJobHop(i);
drawJobHop(hi, false);
}
EImage arrow;
if (candidate != null) {
drawJobHop(candidate, true);
} else {
if (startHopEntry != null && endHopLocation != null) {
Point fr = startHopEntry.getLocation();
Point to = endHopLocation;
if (endHopEntry == null) {
gc.setForeground(EColor.GRAY);
arrow = EImage.ARROW_DISABLED;
} else {
gc.setForeground(EColor.BLUE);
arrow = EImage.ARROW_DEFAULT;
}
Point start = real2screen(fr.x + iconsize / 2, fr.y + iconsize / 2);
Point end = real2screen(to.x, to.y);
drawArrow(arrow, start.x, start.y, end.x, end.y, theta, calcArrowLength(), 1.2, null, startHopEntry, endHopEntry == null ? endHopLocation : endHopEntry);
} else if (endHopEntry != null && endHopLocation != null) {
Point fr = endHopLocation;
Point to = endHopEntry.getLocation();
if (startHopEntry == null) {
gc.setForeground(EColor.GRAY);
arrow = EImage.ARROW_DISABLED;
} else {
gc.setForeground(EColor.BLUE);
arrow = EImage.ARROW_DEFAULT;
}
Point start = real2screen(fr.x, fr.y);
Point end = real2screen(to.x + iconsize / 2, to.y + iconsize / 2);
drawArrow(arrow, start.x, start.y, end.x, end.y + iconsize / 2, theta, calcArrowLength(), 1.2, null, startHopEntry == null ? endHopLocation : startHopEntry, endHopEntry);
}
}
for (int j = 0; j < jobMeta.nrJobEntries(); j++) {
JobEntryCopy je = jobMeta.getJobEntry(j);
drawJobEntryCopy(je);
}
//
if (noInputEntry != null) {
gc.setLineWidth(2);
gc.setForeground(EColor.RED);
Point n = noInputEntry.getLocation();
gc.drawLine(offset.x + n.x - 5, offset.y + n.y - 5, offset.x + n.x + iconsize + 5, offset.y + n.y + iconsize + 5);
gc.drawLine(offset.x + n.x - 5, offset.y + n.y + iconsize + 5, offset.x + n.x + iconsize + 5, offset.y + n.y - 5);
}
if (drop_candidate != null) {
gc.setLineStyle(ELineStyle.SOLID);
gc.setForeground(EColor.BLACK);
Point screen = real2screen(drop_candidate.x, drop_candidate.y);
gc.drawRectangle(screen.x, screen.y, iconsize, iconsize);
}
try {
ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.JobPainterEnd.id, this);
} catch (KettleException e) {
LogChannel.GENERAL.logError("Error in JobPainterEnd extension point", e);
}
if (!shadow) {
drawRect(selrect);
}
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class TransMeta method getMinimum.
/**
* Gets the minimum point on the canvas of a transformation.
*
* @return Minimum coordinate of a step in the transformation
*/
public Point getMinimum() {
int minx = Integer.MAX_VALUE, miny = Integer.MAX_VALUE;
for (int i = 0; i < nrSteps(); i++) {
StepMeta stepMeta = getStep(i);
Point loc = stepMeta.getLocation();
if (loc.x < minx) {
minx = loc.x;
}
if (loc.y < miny) {
miny = loc.y;
}
}
for (int i = 0; i < nrNotes(); i++) {
NotePadMeta notePadMeta = getNote(i);
Point loc = notePadMeta.getLocation();
if (loc.x < minx) {
minx = loc.x;
}
if (loc.y < miny) {
miny = loc.y;
}
}
if (minx > BORDER_INDENT && minx != Integer.MAX_VALUE) {
minx -= BORDER_INDENT;
} else {
minx = 0;
}
if (miny > BORDER_INDENT && miny != Integer.MAX_VALUE) {
miny -= BORDER_INDENT;
} else {
miny = 0;
}
return new Point(minx, miny);
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryNotePadDelegate method loadNotePadMeta.
public NotePadMeta loadNotePadMeta(ObjectId id_note) throws KettleException {
NotePadMeta note = new NotePadMeta();
try {
note.setObjectId(id_note);
RowMetaAndData r = getNote(id_note);
if (r != null) {
note.setNote(r.getString("VALUE_STR", ""));
int x = (int) r.getInteger("GUI_LOCATION_X", 0L);
int y = (int) r.getInteger("GUI_LOCATION_Y", 0L);
note.setLocation(new Point(x, y));
note.setWidth((int) r.getInteger("GUI_LOCATION_WIDTH", 0L));
note.setHeight((int) r.getInteger("GUI_LOCATION_HEIGHT", 0L));
note.setSelected(false);
// Font
note.setFontName(r.getString("FONT_NAME", null));
note.setFontSize((int) r.getInteger("FONT_SIZE", -1));
note.setFontBold(r.getBoolean("FONT_BOLD", false));
note.setFontItalic(r.getBoolean("FONT_ITALIC", false));
// Font color
note.setFontColorRed((int) r.getInteger("FONT_COLOR_RED", NotePadMeta.COLOR_RGB_BLACK_BLUE));
note.setFontColorGreen((int) r.getInteger("FONT_COLOR_GREEN", NotePadMeta.COLOR_RGB_BLACK_GREEN));
note.setFontColorBlue((int) r.getInteger("FONT_COLOR_BLUE", NotePadMeta.COLOR_RGB_BLACK_BLUE));
// Background color
note.setBackGroundColorRed((int) r.getInteger("FONT_BACK_GROUND_COLOR_RED", NotePadMeta.COLOR_RGB_DEFAULT_BG_RED));
note.setBackGroundColorGreen((int) r.getInteger("FONT_BACK_GROUND_COLOR_GREEN", NotePadMeta.COLOR_RGB_DEFAULT_BG_GREEN));
note.setBackGroundColorBlue((int) r.getInteger("FONT_BACK_GROUND_COLOR_BLUE", NotePadMeta.COLOR_RGB_DEFAULT_BG_BLUE));
// Border color
note.setBorderColorRed((int) r.getInteger("FONT_BORDER_COLOR_RED", NotePadMeta.COLOR_RGB_DEFAULT_BORDER_RED));
note.setBorderColorGreen((int) r.getInteger("FONT_BORDER_COLOR_GREEN", NotePadMeta.COLOR_RGB_DEFAULT_BORDER_GREEN));
note.setBorderColorBlue((int) r.getInteger("FONT_BORDER_COLOR_BLUE", NotePadMeta.COLOR_RGB_DEFAULT_BORDER_BLUE));
note.setDrawShadow(r.getBoolean("DRAW_SHADOW", true));
// Done!
return note;
} else {
note.setObjectId(null);
throw new KettleException("I couldn't find Notepad with id_note=" + id_note + " in the repository.");
}
} catch (KettleDatabaseException dbe) {
note.setObjectId(null);
throw new KettleException("Unable to load Notepad from repository (id_note=" + id_note + ")", dbe);
}
}
Aggregations