Example usage for java.awt Graphics drawLine

List of usage examples for java.awt Graphics drawLine

Introduction

In this page you can find the example usage for java.awt Graphics drawLine.

Prototype

public abstract void drawLine(int x1, int y1, int x2, int y2);

Source Link

Document

Draws a line, using the current color, between the points (x1, y1) and (x2, y2) in this graphics context's coordinate system.

Usage

From source file:org.openlegacy.terminal.render.DefaultTerminalSnapshotImageRenderer.java

private void markBackgroundAndInputFields(TerminalSnapshot terminalSnapshot, Graphics graphics) {
    int endX;//  w w  w . j  a  v  a 2  s  .  c  o m
    List<TerminalField> fields = terminalSnapshot.getFields();
    setDefaultColor(graphics);
    for (TerminalField terminalField : fields) {
        TerminalPosition position = terminalField.getPosition();
        // -1 - pixels is 0 based , column is 1 based
        int startX = toWidth(position.getColumn() - 1 + leftColumnsOffset);
        int startY = toHeight(position.getRow());
        endX = toWidth(terminalField.getEndPosition().getColumn() + leftColumnsOffset);
        if (terminalField.isEditable()) {
            graphics.drawLine(startX, startY, endX, startY);
        }
        int rowHeight = toHeight(1);
        if (terminalField.getBackColor() != org.openlegacy.terminal.Color.BLACK) {
            graphics.setColor(SnapshotUtils.convertColor(terminalField.getBackColor()));
            //
            graphics.fillRect(startX, toHeight(position.getRow() - 1) + topPixelsOffset,
                    toWidth(terminalField.getLength()), rowHeight);
        }
    }

    if (drawFieldSeparators) {
        List<TerminalPosition> fieldSeperators = terminalSnapshot.getFieldSeperators();
        graphics.setColor(imageDefaultTextColor);
        for (TerminalPosition terminalPosition : fieldSeperators) {
            graphics.drawString("^", toWidth(terminalPosition.getColumn() - 1 + leftColumnsOffset),
                    toHeight(terminalPosition.getRow()));
        }
    }
}

From source file:rod_design_compute.ShowPanel.java

private void paintSR(SR rodSR, Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    g2d.setStroke(new BasicStroke(2f));

    if (rodSR.flag == true) {
        g2d.setColor(Color.red);/*from   w  w w.ja v  a  2s  .c  o  m*/
        g.drawLine(toScreenX(rodSR.getPointA().X), toScreenY(rodSR.getPointA().Y),
                toScreenX(rodSR.getPointE().X), toScreenY(rodSR.getPointE().Y));
        g.drawLine(toScreenX(rodSR.getPointB().X), toScreenY(rodSR.getPointB().Y),
                toScreenX(rodSR.getPointE().X), toScreenY(rodSR.getPointE().Y));
        drawOtherPoint(rodSR.getPointE(), g);
        g2d.setColor(Color.black);
    }

    g2d.setColor(Color.green);
    g.drawLine(toScreenX(rodSR.getPointA().X), toScreenY(rodSR.getPointA().Y), toScreenX(rodSR.getPointB().X),
            toScreenY(rodSR.getPointB().Y));
    g2d.setColor(Color.black);

    drawBasePoint(rodSR.getPointA(), g);
    drawJunctionPoint(rodSR.getPointB(), g);
}

From source file:de.tor.tribes.ui.views.DSWorkbenchNotepad.java

@Override
public void actionPerformed(ActionEvent e) {

    NoteTableTab activeTab = getActiveTab();
    if (e.getActionCommand() != null && activeTab != null) {
        if (e.getActionCommand().equals("Copy")) {
            activeTab.transferSelection(NoteTableTab.TRANSFER_TYPE.COPY_TO_INTERNAL_CLIPBOARD);
        } else if (e.getActionCommand().equals("BBCopy")) {
            activeTab.transferSelection(NoteTableTab.TRANSFER_TYPE.CLIPBOARD_BB);
        } else if (e.getActionCommand().equals("BBCopy_Village")) {
            activeTab.copyVillagesAsBBCodes();
        } else if (e.getActionCommand().equals("Cut")) {
            activeTab.transferSelection(NoteTableTab.TRANSFER_TYPE.CUT_TO_INTERNAL_CLIPBOARD);
        } else if (e.getActionCommand().equals("Paste")) {
            activeTab.transferSelection(NoteTableTab.TRANSFER_TYPE.FROM_INTERNAL_CLIPBOARD);
        } else if (e.getActionCommand().equals("Delete")) {
            activeTab.deleteSelection(true);
        } else if (e.getActionCommand().equals("Delete_Village")) {
            activeTab.deleteVillagesFromNotes();
        } else if (e.getActionCommand().equals("Find")) {
            BufferedImage back = ImageUtils.createCompatibleBufferedImage(3, 3, BufferedImage.TRANSLUCENT);
            Graphics g = back.getGraphics();
            g.setColor(new Color(120, 120, 120, 120));
            g.fillRect(0, 0, back.getWidth(), back.getHeight());
            g.setColor(new Color(120, 120, 120));
            g.drawLine(0, 0, 3, 3);
            g.dispose();/*  ww  w. ja v  a  2  s .c om*/
            TexturePaint paint = new TexturePaint(back,
                    new Rectangle2D.Double(0, 0, back.getWidth(), back.getHeight()));
            jxSearchPane.setBackgroundPainter(new MattePainter(paint));
            jxSearchPane.setVisible(true);
        }
    }
}

From source file:rod_design_compute.ShowPanel.java

private void paintRRP(RRP rodRRP, Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    g2d.setStroke(new BasicStroke(2f));

    drawSlider(rodRRP.getrodslider(), rodRRP.getPointC(), g);

    drawBlock(rodRRP.getrodslider(), rodRRP.getPointC(), g);

    g.drawLine(toScreenX(rodRRP.getPointB().X), toScreenY(rodRRP.getPointB().Y),
            toScreenX(rodRRP.getPointC().X), toScreenY(rodRRP.getPointC().Y));

    drawJunctionPoint(rodRRP.getPointB(), g);
    drawJunctionPoint(rodRRP.getPointC(), g);
}

From source file:uk.co.modularaudio.mads.base.soundfile_player.ui.SoundfilePlayerWaveDisplayUiJComponent.java

@Override
public void paint(final Graphics g) {
    //      log.trace("WaveDisplay paint() called");
    if (rollPainter != null) {
        if (rollPainter.buffer0Visible()) {
            g.drawImage(rollPainter.buffer0.bi, rollPainter.buffer0XOffset, 0, null);
        }//from  ww w .j ava  2 s.  c om
        if (rollPainter.buffer1Visible()) {
            g.drawImage(rollPainter.buffer1.bi, rollPainter.buffer1XOffset, 0, null);
        }
    } else {
        g.setColor(SoundfilePlayerColorDefines.WAVE_DISPLAY_BACKGROUND_COLOR);
        g.fillRect(0, 0, displayWidth, displayHeight);
    }
    g.setColor(SoundfilePlayerColorDefines.WAVE_DISPLAY_CURRENT_POSITION_COLOUR);
    g.drawLine(displayWidthMinusOneOverTwo, 0, displayWidthMinusOneOverTwo, displayHeight);
}

From source file:javazoom.jlgui.player.amp.visual.ui.SpectrumTimeAnalyzer.java

private void drawScope(Graphics pGrp, float[] pSample) {
    pGrp.setColor(scopeColor);//from  www. ja v  a 2  s. c o m
    int wLas = (int) (pSample[0] * (float) height_2) + height_2;
    int wSt = 2;
    for (int a = wSt, c = 0; c < width; a += wSt, c++) {
        int wAs = (int) (pSample[a] * (float) height_2) + height_2;
        pGrp.drawLine(c, wLas, c + 1, wAs);
        wLas = wAs;
    }
}

From source file:rod_design_compute.ShowPanel.java

private void paintRRR(RRR rodRRR, Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    g2d.setStroke(new BasicStroke(2f));

    if (rodRRR.flag2 == true || rodRRR.flag3 == true) {
        g2d.setColor(Color.red);/* w w w.j  av  a2s .  c  om*/
        if (rodRRR.flag2 == true) {
            g.drawLine(toScreenX(rodRRR.getPointB().X), toScreenY(rodRRR.getPointB().Y),
                    toScreenX(rodRRR.getPointE().X), toScreenY(rodRRR.getPointE().Y));
        } else if (rodRRR.flag3 == true) {
            g.drawLine(toScreenX(rodRRR.getPointD().X), toScreenY(rodRRR.getPointD().Y),
                    toScreenX(rodRRR.getPointE().X), toScreenY(rodRRR.getPointE().Y));
        }
        g.drawLine(toScreenX(rodRRR.getPointC().X), toScreenY(rodRRR.getPointC().Y),
                toScreenX(rodRRR.getPointE().X), toScreenY(rodRRR.getPointE().Y));
        drawOtherPoint(rodRRR.getPointE(), g);
        g2d.setColor(Color.black);
    }

    g.drawLine(toScreenX(rodRRR.getPointB().X), toScreenY(rodRRR.getPointB().Y),
            toScreenX(rodRRR.getPointC().X), toScreenY(rodRRR.getPointC().Y));

    g.drawLine(toScreenX(rodRRR.getPointC().X), toScreenY(rodRRR.getPointC().Y),
            toScreenX(rodRRR.getPointD().X), toScreenY(rodRRR.getPointD().Y));

    drawJunctionPoint(rodRRR.getPointB(), g);
    drawJunctionPoint(rodRRR.getPointC(), g);
    drawBasePoint(rodRRR.getPointD(), g);
}

From source file:de.tor.tribes.ui.views.DSWorkbenchConquersFrame.java

@Override
public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals("Find")) {
        BufferedImage back = ImageUtils.createCompatibleBufferedImage(3, 3, BufferedImage.TRANSLUCENT);
        Graphics g = back.getGraphics();
        g.setColor(new Color(120, 120, 120, 120));
        g.fillRect(0, 0, back.getWidth(), back.getHeight());
        g.setColor(new Color(120, 120, 120));
        g.drawLine(0, 0, 3, 3);
        g.dispose();//from  w  w w . j a v a2s  .  co m
        TexturePaint paint = new TexturePaint(back,
                new Rectangle2D.Double(0, 0, back.getWidth(), back.getHeight()));
        jxFilterPane.setBackgroundPainter(new MattePainter(paint));
        DefaultListModel model = new DefaultListModel();

        for (int i = 0; i < jConquersTable.getColumnCount(); i++) {
            TableColumnExt col = jConquersTable.getColumnExt(i);
            if (col.isVisible() && !col.getTitle().equals("Entfernung")
                    && !col.getTitle().equals("Dorfpunkte")) {
                model.addElement(col.getTitle());
            }
        }
        jXColumnList.setModel(model);
        jXColumnList.setSelectedIndex(0);
        jxFilterPane.setVisible(true);
    }
}

From source file:CustomAlphaTest.java

protected void drawGraphLine(Graphics g, double x1, double y1, double x2, double y2) {
    g.drawLine((int) (m_nGraphInsetX + x1), (int) (m_nGraphInsetY + m_nGraphMaxHeight - y1),
            (int) (m_nGraphInsetX + x2), (int) (m_nGraphInsetY + m_nGraphMaxHeight - y2));
}

From source file:de.tor.tribes.ui.views.DSWorkbenchTroopsFrame.java

@Override
public void actionPerformed(ActionEvent e) {
    TroopTableTab activeTab = getActiveTab();
    if (e.getActionCommand().equals("Delete")) {
        if (activeTab != null) {
            activeTab.deleteSelection();
        }//from  w w w.ja  v  a  2  s.  co m
    } else if (e.getActionCommand().equals("BBCopy")) {
        if (activeTab != null) {
            activeTab.transferSelection(TroopTableTab.TRANSFER_TYPE.CLIPBOARD_BB);
        }
    } else if (e.getActionCommand().equals("Find")) {
        BufferedImage back = ImageUtils.createCompatibleBufferedImage(3, 3, BufferedImage.TRANSLUCENT);
        Graphics g = back.getGraphics();
        g.setColor(new Color(120, 120, 120, 120));
        g.fillRect(0, 0, back.getWidth(), back.getHeight());
        g.setColor(new Color(120, 120, 120));
        g.drawLine(0, 0, 3, 3);
        g.dispose();
        TexturePaint paint = new TexturePaint(back,
                new Rectangle2D.Double(0, 0, back.getWidth(), back.getHeight()));
        jxSearchPane.setBackgroundPainter(new MattePainter(paint));
        updateTagList();
        jxSearchPane.setVisible(true);
    } else if (e.getActionCommand() != null && activeTab != null) {
        if (e.getActionCommand().equals("SelectionDone")) {
            activeTab.updateSelectionInfo();
        }
    }
}