Search in sources :

Example 6 with Problem

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;
        }
    }
}
Also used : SketchCode(processing.app.SketchCode) Sketch(processing.app.Sketch) Problem(processing.app.Problem)

Example 7 with Problem

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();
    }
}
Also used : Problem(processing.app.Problem)

Example 8 with Problem

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);
    }
}
Also used : Problem(processing.app.Problem) PdeTextArea(processing.app.syntax.PdeTextArea)

Aggregations

Problem (processing.app.Problem)8 Point (java.awt.Point)2 java.awt.print (java.awt.print)2 Sketch (processing.app.Sketch)2 SketchCode (processing.app.SketchCode)2 BorderLayout (java.awt.BorderLayout)1 Color (java.awt.Color)1 Component (java.awt.Component)1 Dimension (java.awt.Dimension)1 EventQueue (java.awt.EventQueue)1 Font (java.awt.Font)1 Frame (java.awt.Frame)1 Image (java.awt.Image)1 Window (java.awt.Window)1 java.awt.datatransfer (java.awt.datatransfer)1 java.awt.event (java.awt.event)1 java.io (java.io)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1