1 | /* |
---|
2 | * $Id: StrokeDrawer1.java,v 1.2 2001/12/11 21:31:42 dwd Exp $ |
---|
3 | * |
---|
4 | * This software is provided by NOAA for full, free and open release. It is |
---|
5 | * understood by the recipient/user that NOAA assumes no liability for any |
---|
6 | * errors contained in the code. Although this software is released without |
---|
7 | * conditions or restrictions in its use, it is expected that appropriate |
---|
8 | * credit be given to its author and to the National Oceanic and Atmospheric |
---|
9 | * Administration should the software be included by the recipient as an |
---|
10 | * element in other product development. |
---|
11 | */ |
---|
12 | |
---|
13 | package gov.noaa.pmel.sgt; |
---|
14 | |
---|
15 | import java.awt.*; |
---|
16 | |
---|
17 | /** |
---|
18 | * Implements stroke drawing for JDK1.1 |
---|
19 | * |
---|
20 | * @author Donald Denbo |
---|
21 | * @version $Revision: 1.2 $, $Date: 2001/12/11 21:31:42 $ |
---|
22 | * @since 2.1 |
---|
23 | */ |
---|
24 | public class StrokeDrawer1 implements StrokeDrawer, Cloneable { |
---|
25 | |
---|
26 | public void drawHeavy(Graphics g, int[] xout, int[] yout, int size, |
---|
27 | LineAttribute attr) { |
---|
28 | g.drawPolyline(xout, yout, size); |
---|
29 | } |
---|
30 | |
---|
31 | public void drawDashed(Graphics g, int[] xout, int[] yout, int size, |
---|
32 | LineAttribute attr) { |
---|
33 | g.drawPolyline(xout, yout, size); |
---|
34 | } |
---|
35 | |
---|
36 | public void drawStroke(Graphics g, int[] xout, int[] yout, int size, |
---|
37 | LineAttribute attr) { |
---|
38 | g.drawPolyline(xout, yout, size); |
---|
39 | } |
---|
40 | |
---|
41 | public void drawHighlight(Graphics g, int[] x, int[] y, int size, |
---|
42 | LineAttribute attr) { |
---|
43 | int[] xr = new int[size]; |
---|
44 | int[] yr = new int[size]; |
---|
45 | int i; |
---|
46 | Color col = attr.getColor(); |
---|
47 | Color rev = new Color(255 - col.getRed(), |
---|
48 | 255 - col.getGreen(), |
---|
49 | 255 - col.getBlue()); |
---|
50 | // |
---|
51 | // simple hightlight draw with pixel displacements in reverse |
---|
52 | // color |
---|
53 | // |
---|
54 | g.setPaintMode(); |
---|
55 | for(i=0; i < size; i++) { |
---|
56 | xr[i] = x[i] + 1; |
---|
57 | yr[i] = y[i] + 1; |
---|
58 | } |
---|
59 | g.setColor(col); |
---|
60 | g.drawPolyline(xr, yr, size); |
---|
61 | for(i=0; i < size; i++) { |
---|
62 | xr[i] = x[i] - 1; |
---|
63 | yr[i] = y[i] - 1; |
---|
64 | } |
---|
65 | g.drawPolyline(xr, yr, size); |
---|
66 | g.setColor(rev); |
---|
67 | g.drawPolyline(x, y, size); |
---|
68 | } |
---|
69 | } |
---|