use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class TransPainter method drawArrow.
@Override
protected void drawArrow(EImage arrow, int x1, int y1, int x2, int y2, double theta, int size, double factor, TransHopMeta transHop, Object startObject, Object endObject) {
int mx, my;
int a, b, dist;
double angle;
gc.drawLine(x1, y1, x2, y2);
// in between 2 points
mx = x1 + (x2 - x1) / 2;
my = y1 + (y2 - y1) / 2;
a = Math.abs(x2 - x1);
b = Math.abs(y2 - y1);
dist = (int) Math.sqrt(a * a + b * b);
// 0-->100%)
if (factor < 0) {
if (dist >= 2 * iconsize) {
factor = 1.3;
} else {
factor = 1.2;
}
}
// in between 2 points
mx = (int) (x1 + factor * (x2 - x1) / 2);
my = (int) (y1 + factor * (y2 - y1) / 2);
// calculate points for arrowhead
// calculate points for arrowhead
angle = Math.atan2(y2 - y1, x2 - x1) + (Math.PI / 2);
boolean q1 = Math.toDegrees(angle) >= 0 && Math.toDegrees(angle) <= 90;
boolean q2 = Math.toDegrees(angle) > 90 && Math.toDegrees(angle) <= 180;
boolean q3 = Math.toDegrees(angle) > 180 && Math.toDegrees(angle) <= 270;
boolean q4 = Math.toDegrees(angle) > 270 || Math.toDegrees(angle) < 0;
if (q1 || q3) {
gc.drawImage(arrow, mx + 1, my, magnification, angle);
} else if (q2 || q4) {
gc.drawImage(arrow, mx, my, magnification, angle);
}
if (startObject instanceof StepMeta && endObject instanceof StepMeta) {
factor = 0.8;
StepMeta fs = (StepMeta) startObject;
StepMeta ts = (StepMeta) endObject;
// in between 2 points
mx = (int) (x1 + factor * (x2 - x1) / 2) - 8;
my = (int) (y1 + factor * (y2 - y1) / 2) - 8;
boolean errorHop = fs.isSendingErrorRowsToStep(ts) || (startErrorHopStep && fs.equals(startHopStep));
boolean targetHop = Const.indexOfString(ts.getName(), fs.getStepMetaInterface().getStepIOMeta().getTargetStepnames()) >= 0;
if (targetHop) {
StepIOMetaInterface ioMeta = fs.getStepMetaInterface().getStepIOMeta();
StreamInterface targetStream = ioMeta.findTargetStream(ts);
if (targetStream != null) {
EImage hopsIcon = BasePainter.getStreamIconImage(targetStream.getStreamIcon());
Point bounds = gc.getImageBounds(hopsIcon);
gc.drawImage(hopsIcon, mx, my, magnification);
if (!shadow) {
areaOwners.add(new AreaOwner(AreaType.STEP_TARGET_HOP_ICON, mx, my, bounds.x, bounds.y, offset, fs, targetStream));
}
}
} else if (fs.isDistributes() && fs.getRowDistribution() != null && !ts.getStepPartitioningMeta().isMethodMirror() && !errorHop) {
// Draw the custom row distribution plugin icon
//
EImage eImage = fs.getRowDistribution().getDistributionImage();
if (eImage != null) {
Point bounds = gc.getImageBounds(eImage);
gc.drawImage(eImage, mx, my, magnification);
if (!shadow) {
areaOwners.add(new AreaOwner(AreaType.ROW_DISTRIBUTION_ICON, mx, my, bounds.x, bounds.y, offset, fs, STRING_ROW_DISTRIBUTION));
}
mx += 16;
}
} else if (!fs.isDistributes() && !ts.getStepPartitioningMeta().isMethodMirror() && !errorHop) {
// Draw the copy icon on the hop
//
Point bounds = gc.getImageBounds(EImage.COPY_ROWS);
gc.drawImage(EImage.COPY_ROWS, mx, my, magnification);
if (!shadow) {
areaOwners.add(new AreaOwner(AreaType.HOP_COPY_ICON, mx, my, bounds.x, bounds.y, offset, fs, STRING_HOP_TYPE_COPY));
}
mx += 16;
}
if (errorHop) {
Point bounds = gc.getImageBounds(EImage.COPY_ROWS);
gc.drawImage(EImage.FALSE, mx, my, magnification);
if (!shadow) {
areaOwners.add(new AreaOwner(AreaType.HOP_ERROR_ICON, mx, my, bounds.x, bounds.y, offset, fs, ts));
}
mx += 16;
}
StepIOMetaInterface ioMeta = ts.getStepMetaInterface().getStepIOMeta();
String[] infoStepnames = ioMeta.getInfoStepnames();
if ((candidateHopType == StreamType.INFO && ts.equals(endHopStep) && fs.equals(startHopStep)) || Const.indexOfString(fs.getName(), infoStepnames) >= 0) {
Point bounds = gc.getImageBounds(EImage.INFO);
gc.drawImage(EImage.INFO, mx, my, magnification);
if (!shadow) {
areaOwners.add(new AreaOwner(AreaType.HOP_INFO_ICON, mx, my, bounds.x, bounds.y, offset, fs, ts));
}
mx += 16;
}
//
if (!Utils.isEmpty(infoStepnames)) {
//
for (String infoStep : infoStepnames) {
if (fs.getName().equalsIgnoreCase(infoStep)) {
//
if (fs.getCopies() > 1) {
// This is not a desirable situation, it will always end in error.
// As such, it's better not to give feedback on it.
// We do this by drawing an error icon over the hop...
//
gc.drawImage(EImage.ERROR, mx, my, magnification);
if (!shadow) {
areaOwners.add(new AreaOwner(AreaType.HOP_INFO_STEP_COPIES_ERROR, mx, my, MINI_ICON_SIZE, MINI_ICON_SIZE, offset, fs, ts));
}
mx += 16;
}
}
}
}
}
TransPainterExtension extension = new TransPainterExtension(gc, shadow, areaOwners, transMeta, null, transHop, x1, y1, x2, y2, mx, my, offset, iconsize);
try {
ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.TransPainterArrow.id, extension);
} catch (Exception e) {
LogChannel.GENERAL.logError("Error calling extension point(s) for the transformation painter arrow", e);
}
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class TransPainter method checkDrawSlowStepIndicator.
private void checkDrawSlowStepIndicator(StepMeta stepMeta) {
if (stepMeta == null) {
return;
}
// draw optional performance indicator
if (trans != null) {
Point pt = stepMeta.getLocation();
if (pt == null) {
pt = new Point(50, 50);
}
Point screen = real2screen(pt.x, pt.y);
int x = screen.x;
int y = screen.y;
List<StepInterface> steps = trans.findBaseSteps(stepMeta.getName());
for (StepInterface step : steps) {
if (step.isRunning()) {
int inputRows = step.rowsetInputSize();
int outputRows = step.rowsetOutputSize();
// if the step can't keep up with its input, mark it by drawing an animation
boolean isSlow = inputRows * 0.85 > outputRows;
if (isSlow) {
gc.setLineWidth(linewidth + 1);
if (System.currentTimeMillis() % 2000 > 1000) {
gc.setForeground(EColor.BACKGROUND);
gc.setLineStyle(ELineStyle.SOLID);
gc.drawRectangle(x + 1, y + 1, iconsize - 2, iconsize - 2);
gc.setForeground(EColor.DARKGRAY);
gc.setLineStyle(ELineStyle.DOT);
gc.drawRectangle(x + 1, y + 1, iconsize - 2, iconsize - 2);
} else {
gc.setForeground(EColor.DARKGRAY);
gc.setLineStyle(ELineStyle.SOLID);
gc.drawRectangle(x + 1, y + 1, iconsize - 2, iconsize - 2);
gc.setForeground(EColor.BACKGROUND);
gc.setLineStyle(ELineStyle.DOT);
gc.drawRectangle(x + 1, y + 1, iconsize - 2, iconsize - 2);
}
}
}
gc.setLineStyle(ELineStyle.SOLID);
}
}
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class TransPainter method drawStepStatusIndicator.
private void drawStepStatusIndicator(StepMeta stepMeta) {
if (stepMeta == null) {
return;
}
// draw status indicator
if (trans != null) {
Point pt = stepMeta.getLocation();
if (pt == null) {
pt = new Point(50, 50);
}
Point screen = real2screen(pt.x, pt.y);
int x = screen.x;
int y = screen.y;
List<StepInterface> steps = trans.findBaseSteps(stepMeta.getName());
for (StepInterface step : steps) {
if (step.getStatus().equals(StepExecutionStatus.STATUS_FINISHED)) {
gc.drawImage(EImage.TRUE, (x + iconsize) - (MINI_ICON_SIZE / 2) + 4, y - (MINI_ICON_SIZE / 2) - 1, magnification);
}
}
}
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryNotePadDelegate method saveNotePadMeta.
/**
* @param rep
* @param id_transformation
* @throws KettleException
*/
public void saveNotePadMeta(NotePadMeta note, ObjectId id_transformation) throws KettleException {
try {
Point location = note.getLocation();
int x = location == null ? -1 : location.x;
int y = location == null ? -1 : location.y;
// Insert new Note in repository
note.setObjectId(insertNote(note.getNote(), x, y, note.getWidth(), note.getHeight(), note.getFontName(), note.getFontSize(), note.isFontBold(), note.isFontItalic(), note.getFontColorRed(), note.getFontColorGreen(), note.getFontColorBlue(), note.getBackGroundColorRed(), note.getBackGroundColorGreen(), note.getBackGroundColorBlue(), note.getBorderColorRed(), note.getBorderColorGreen(), note.getBorderColorBlue(), note.isDrawShadow()));
} catch (KettleDatabaseException dbe) {
throw new KettleException("Unable to save notepad in repository (id_transformation=" + id_transformation + ")", dbe);
}
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class AbstractMeta method addUndo.
/*
* (non-Javadoc)
*
* @see org.pentaho.di.core.gui.UndoInterface#addUndo(java.lang.Object[], java.lang.Object[], int[],
* org.pentaho.di.core.gui.Point[], org.pentaho.di.core.gui.Point[], int, boolean)
*/
@Override
public void addUndo(Object[] from, Object[] to, int[] pos, Point[] prev, Point[] curr, int type_of_change, boolean nextAlso) {
while (undo.size() > undo_position + 1 && undo.size() > 0) {
int last = undo.size() - 1;
undo.remove(last);
}
TransAction ta = new TransAction();
switch(type_of_change) {
case TYPE_UNDO_CHANGE:
ta.setChanged(from, to, pos);
break;
case TYPE_UNDO_DELETE:
ta.setDelete(from, pos);
break;
case TYPE_UNDO_NEW:
ta.setNew(from, pos);
break;
case TYPE_UNDO_POSITION:
ta.setPosition(from, pos, prev, curr);
break;
default:
break;
}
undo.add(ta);
undo_position++;
if (undo.size() > max_undo) {
undo.remove(0);
undo_position--;
}
}
Aggregations