use of processing.app.Problem in project processing by processing.
the class MarkerColumn method recalculateMarkerPositions.
private void recalculateMarkerPositions() {
if (errorPoints != null && errorPoints.size() > 0) {
Sketch sketch = editor.getSketch();
SketchCode code = sketch.getCurrentCode();
int currentTab = sketch.getCurrentCodeIndex();
// do not divide by zero
int totalLines = PApplet.max(1, code.getLineCount());
int visibleLines = editor.getTextArea().getVisibleLines();
totalLines = PApplet.max(totalLines, visibleLines);
// top scroll button
int topMargin = 20;
// bottom scroll button and horizontal scrollbar
int bottomMargin = 40;
int height = getHeight() - topMargin - bottomMargin;
for (LineMarker m : errorPoints) {
Problem problem = m.problem;
if (problem.getTabIndex() != currentTab)
continue;
// Ratio of error line to total lines
float ratio = (problem.getLineNumber() + 1) / ((float) totalLines);
// Ratio multiplied by height of the error bar
float y = topMargin + ratio * height;
m.y = (int) y;
}
}
}
use of processing.app.Problem in project processing by processing.
the class MarkerColumn method showMarkerHover.
/** Show tooltip on hover. */
private void showMarkerHover(final int y) {
try {
LineMarker m = findClosestMarker(y);
if (m != null) {
Problem p = m.problem;
editor.statusToolTip(MarkerColumn.this, p.getMessage(), p.isError());
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
use of processing.app.Problem in project processing by processing.
the class MarkerColumn method paintComponent.
@Override
public void paintComponent(Graphics g) {
PdeTextArea pta = editor.getPdeTextArea();
if (pta != null) {
g.drawImage(pta.getGutterGradient(), 0, 0, getWidth(), getHeight(), this);
}
int currentTabIndex = editor.getSketch().getCurrentCodeIndex();
for (LineMarker m : errorPoints) {
Problem problem = m.problem;
if (problem.getTabIndex() != currentTabIndex)
continue;
if (problem.isError()) {
g.setColor(errorColor);
} else {
g.setColor(warningColor);
}
g.drawLine(2, m.y, getWidth() - 2, m.y);
}
}
Aggregations