001: /*
002: * Copyright (C) 2005 - 2008 JasperSoft Corporation. All rights reserved.
003: * http://www.jaspersoft.com.
004: *
005: * Unless you have purchased a commercial license agreement from JasperSoft,
006: * the following license terms apply:
007: *
008: * This program is free software; you can redistribute it and/or modify
009: * it under the terms of the GNU General Public License version 2 as published by
010: * the Free Software Foundation.
011: *
012: * This program is distributed WITHOUT ANY WARRANTY; and without the
013: * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
014: * See the GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
018: * or write to:
019: *
020: * Free Software Foundation, Inc.,
021: * 59 Temple Place - Suite 330,
022: * Boston, MA USA 02111-1307
023: *
024: *
025: *
026: *
027: * JRulePanel.java
028: *
029: * Created on 12 febbraio 2003, 22.52
030: *
031: */
032:
033: package it.businesslogic.ireport.gui;
034:
035: import it.businesslogic.ireport.Band;
036: import java.awt.event.MouseEvent;
037: import java.awt.geom.AffineTransform;
038: import java.util.Iterator;
039: import javax.swing.*;
040: import java.awt.*;
041: import it.businesslogic.ireport.util.*;
042:
043: /**
044: *
045: * @author Administrator
046: */
047: public class JRulePanel extends JPanel {
048:
049: public static int TYPE_HORIZONTAL = 0;
050: public static int TYPE_VERTICAL = 1;
051:
052: private boolean fontSet = false;
053: private JReportFrame jReportFrame = null;
054:
055: private int type = TYPE_HORIZONTAL;
056:
057: private int cursorPosition;
058:
059: private boolean dragging = false;
060: private java.awt.image.BufferedImage savedImage = null;
061: private ImageIcon horizontalRuleStopIcon = null;
062:
063: private java.util.List guideLines = new java.util.ArrayList();
064: private int lastTempGuidePosition = -1;
065: private Stroke dottedStroke = null;
066:
067: /** Creates a new instance of JRulePane */
068: public JRulePanel() {
069: setCursorPosition(-1);
070: Font f = this .getFont();
071: this .setFont(new Font(f.getName(), 0, 10)); //f.getFamily())
072:
073: setDottedStroke((Stroke) new BasicStroke((float) (1f),
074: BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0f,
075: new float[] { 1f, 1f }, 0f));
076:
077: horizontalRuleStopIcon = new javax.swing.ImageIcon(
078: getClass()
079: .getResource(
080: "/it/businesslogic/ireport/icons/toolbars/rulestop.png"));
081:
082: addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
083: public void mouseDragged(java.awt.event.MouseEvent evt) {
084: panelMouseDragged(evt);
085: }
086:
087: public void mouseMoved(java.awt.event.MouseEvent evt) {
088: panelMouseMoved(evt);
089: }
090: });
091:
092: addMouseListener(new java.awt.event.MouseAdapter() {
093: public void mousePressed(java.awt.event.MouseEvent evt) {
094: panelMousePressed(evt);
095: }
096:
097: public void mouseReleased(java.awt.event.MouseEvent evt) {
098: panelMouseReleased(evt);
099: }
100: });
101: }
102:
103: public void setRightFont(Graphics g) {
104: if (fontSet)
105: return;
106:
107: if (g == null)
108: return;
109: /*
110: Font f = g.getFont();
111: f = new Font( f.getName(), 0, 10); //f.getFamily()
112: g.setFont(f);
113: */
114: //setFont(f); //f.getFamily()
115: //fontSet = true;
116: }
117:
118: /**
119: * Paints the container. This forwards the paint to any lightweight
120: * components that are children of this container. If this method is
121: * reimplemented, super.paint(g) should be called so that lightweight
122: * components are properly rendered. If a child component is entirely
123: * clipped by the current clipping setting in g, paint() will not be
124: * forwarded to that child.
125: *
126: * @param g the specified Graphics window
127: * @see Component#update(Graphics)
128: *
129: * 0 10 x1 x2 x3
130: * +-----+-----+------------------------------------+-----+-------
131: * | |:::::|::::::::::::::::::::::::::::::::::::|:::::|
132: * | |:::::|::::::::::::::::::::::::::::::::::::|:::::|
133: *
134: * <============= scroll_h =========================================>
135: *
136: * x1 = Margin left position
137: * x2 = Margin right position
138: * x3 = Page width position
139: * scroll_h = horizontal position of the scroll bar.
140: *
141: */
142: public void paint(Graphics g) {
143:
144: if (getJReportFrame() == null)
145: return;
146: setRightFont(g);
147: g.setFont(this .getFont());
148: setCursorPosition(-1);
149:
150: //g.setColor(new Color( 255,255,255));
151: g.setColor(this .getBackground());
152: g.fillRect(0, 0, this .getWidth(), this .getHeight());
153:
154: String unitName = MainFrame.getMainInstance().getProperties()
155: .getProperty("DefaultUnit", "cm");
156: double unit = Unit.CENTIMETERS;
157: if (unitName.equals("cm"))
158: unit = Unit.CENTIMETERS;
159: else if (unitName.equals("pixels"))
160: unit = Unit.PIXEL;
161: else if (unitName.equals("mm"))
162: unit = Unit.MILLIMETERS;
163: else if (unitName.equals("inches"))
164: unit = Unit.INCHES;
165:
166: g.setColor(new Color(255, 255, 255));
167:
168: double k = 0;
169:
170: double zoomfactor = getJReportFrame().getZoomFactor();
171:
172: int line = 0;
173: int i = 0;
174: //int i = 10-HScrollBar1.getValue();
175: int oldi = -100;
176: double module = 2;
177:
178: boolean isMillimeters = (unit == Unit.MILLIMETERS);
179: if (isMillimeters) {
180: unit = Unit.CENTIMETERS;
181: }
182:
183: boolean isPixel = false;
184: // Choose module...
185: int tick_space = 50;
186: if (unit == Unit.PIXEL) {
187: isPixel = true;
188: unit = 50;
189: tick_space = 100;
190: }
191:
192: if (((int) (convertUnitToPixel(1, unit) * zoomfactor)) >= tick_space) {
193: module = 10;
194: }
195:
196: if (getType() == TYPE_HORIZONTAL) {
197: int x1 = 10
198: + getJReportFrame().getZoomedDim(
199: getJReportFrame().getReport()
200: .getLeftMargin())
201: - getJReportFrame().getHScroll();
202: int x2 = 10
203: + getJReportFrame().getZoomedDim(
204: getJReportFrame().getReport().getWidth()
205: - getJReportFrame().getReport()
206: .getRightMargin())
207: - getJReportFrame().getHScroll();
208: int x3 = 10
209: + getJReportFrame().getZoomedDim(
210: getJReportFrame().getReport().getWidth())
211: - getJReportFrame().getHScroll() - 1;
212:
213: g.fillRect(Math.max(x1, 0), 0, Math
214: .min(x2, this .getWidth())
215: - Math.max(x1, 0), this .getHeight());
216:
217: java.awt.Color c = this .getBackground().darker();
218: if (x1 > 0) {
219: g.setColor(c);
220: g.fillRect(Math.max(
221: 10 - getJReportFrame().getHScroll(), 0), 0, x1
222: - Math.max(10 - getJReportFrame().getHScroll(),
223: 0), this .getHeight());
224: g.setColor(c.darker());
225: g.drawRect(Math.max(
226: 10 - getJReportFrame().getHScroll(), 0), 0, x1
227: - Math.max(10 - getJReportFrame().getHScroll(),
228: 0), this .getHeight());
229: }
230:
231: if (x2 < this .getWidth()) {
232: g.setColor(c);
233: g.fillRect(x2, 0, Math.min(this .getWidth(), x3) - x2,
234: this .getHeight());
235: g.setColor(c.darker());
236: g.drawRect(x2, 0, Math.min(this .getWidth(), x3) - x2,
237: this .getHeight());
238: }
239:
240: g.setColor(new Color(0, 0, 0));
241: g.drawLine(0, this .getHeight() - 1, this .getWidth(), this
242: .getHeight() - 1);
243:
244: i = x1;
245:
246: while (i < this .getWidth()) {
247: if (i >= 0) {
248: if ((line % module) == 0) {
249: if (i - oldi > 20) {
250: String s = "" + (int) k;
251: if (isMillimeters)
252: s += "0";
253: if (isPixel)
254: s = "" + ((int) k * 50);
255:
256: int w = g.getFontMetrics().stringWidth(s);
257: g
258: .drawString(s, i - (w / 2), (g
259: .getFontMetrics()
260: .getHeight() / 2) + 3);
261: //writeRotateString((Graphics2D)g,i - (w/2), (g.getFontMetrics().getHeight()/2)+3, s);
262: oldi = i;
263: g.drawLine(i, 16, i, 12);
264: } else {
265: g.drawLine(i, 5, i, 10);
266: }
267:
268: } else {
269: if (module == 10 && (line % 5) != 0) {
270: g.drawLine(i, 7, i, 8);
271: } else {
272: g.drawLine(i, 6, i, 9);
273: }
274: }
275: }
276: line++;
277: k = line * (1.0 / module);
278: i = x1
279: + (int) (convertUnitToPixel(k, unit) * zoomfactor);
280:
281: }
282:
283: line = 1;
284: k = 1.0 / module;
285: oldi = x1;
286: i = x1 - (int) (convertUnitToPixel(k, unit) * zoomfactor);
287: while (x1 > 0 && i > -10) {
288: if (i >= 0) {
289: if ((line % module) == 0) {
290: if (oldi - i > 20) {
291: String s = "" + (int) k;
292: if (isMillimeters)
293: s += "0";
294: if (isPixel)
295: s = "" + ((int) k * 50);
296:
297: int w = g.getFontMetrics().stringWidth(s);
298: g
299: .drawString(s, i - (w / 2), (g
300: .getFontMetrics()
301: .getHeight() / 2) + 3);
302: oldi = i;
303: g.drawLine(i, 16, i, 12);
304: } else {
305: g.drawLine(i, 5, i, 10);
306: }
307:
308: } else {
309: if (module == 10 && (line % 5) != 0) {
310: g.drawLine(i, 7, i, 8);
311: } else {
312: g.drawLine(i, 6, i, 9);
313: }
314: }
315: }
316: line++;
317: k = line * (1.0 / module);
318: i = x1
319: - (int) (convertUnitToPixel(k, unit) * zoomfactor);
320: }
321:
322: for (i = 0; i < getGuideLines().size(); ++i) {
323: Integer pos = (Integer) getGuideLines().get(i);
324: int posI = pos.intValue();
325: // Calc posI....
326: posI = 10 + (int) (posI * zoomfactor)
327: - getJReportFrame().getHScroll();
328: g.drawImage(horizontalRuleStopIcon.getImage(),
329: posI - 4, 7, this );
330: }
331:
332: } else // VERTICAL.....
333: {
334: int y1 = 10
335: + getJReportFrame().getZoomedDim(
336: getJReportFrame().getReport()
337: .getTopMargin())
338: - getJReportFrame().getVScroll();
339: int y2 = 10
340: + getJReportFrame().getZoomedDim(
341: getJReportFrame().getReport()
342: .getDesignHeight()
343: - getJReportFrame().getReport()
344: .getBottomMargin())
345: - getJReportFrame().getVScroll();
346: int y3 = 10
347: + getJReportFrame().getZoomedDim(
348: getJReportFrame().getReport()
349: .getDesignHeight())
350: - getJReportFrame().getVScroll() - 1;
351:
352: g.fillRect(0, Math.max(y1, 0), this .getWidth(), Math.min(
353: y2, this .getHeight())
354: - Math.max(y1, 0));
355:
356: java.awt.Color c = this .getBackground().darker();
357: if (y1 > 0) {
358: g.setColor(c);
359: g.fillRect(0, Math.max(10 - getJReportFrame()
360: .getVScroll(), 0), this .getWidth(), y1
361: - Math.max(10 - getJReportFrame().getVScroll(),
362: 0));
363: g.setColor(c.darker());
364: g.drawRect(0, Math.max(10 - getJReportFrame()
365: .getVScroll(), 0), this .getWidth(), y1
366: - Math.max(10 - getJReportFrame().getVScroll(),
367: 0));
368: }
369:
370: if (y2 < this .getHeight()) {
371: g.setColor(c);
372: g.fillRect(0, y2, this .getWidth(), Math.min(this
373: .getHeight(), y3)
374: - y2);
375: g.setColor(c.darker());
376: g.drawRect(0, y2, this .getWidth(), Math.min(this
377: .getHeight(), y3)
378: - y2);
379: }
380:
381: // Write final gray....
382: if (y2 < this .getHeight()) {
383: g.setColor(c);
384: g.fillRect(0, y2, this .getWidth(), Math.min(this
385: .getHeight(), y3)
386: - y2);
387: g.setColor(c.darker());
388: g.drawRect(0, y2, this .getWidth(), Math.min(this
389: .getHeight(), y3)
390: - y2);
391: }
392:
393: g.setColor(new Color(0, 0, 0));
394: g.drawLine(this .getWidth() - 1, 0, this .getWidth() - 1,
395: this .getHeight());
396:
397: Iterator iterBands = getJReportFrame().getReport()
398: .getBands().iterator();
399:
400: // Draw bands colors...
401: Color mygray = new Color(220, 220, 220);
402: boolean useWhite = true;
403: while (iterBands.hasNext()) {
404: Band currentBand = (Band) iterBands.next();
405: if (currentBand.getHeight() == 0)
406: continue;
407:
408: int bandStartY = getJReportFrame().getReport()
409: .getBandYLocation(currentBand);
410: bandStartY = 10
411: + getJReportFrame().getZoomedDim(bandStartY)
412: - getJReportFrame().getVScroll();
413:
414: int bandEndY = getJReportFrame().getReport()
415: .getBandYLocation(currentBand)
416: + currentBand.getHeight();
417: bandEndY = 10
418: + getJReportFrame().getZoomedDim(bandEndY)
419: - getJReportFrame().getVScroll();
420:
421: if (bandStartY < this .getHeight() && bandEndY > 0) {
422: g.setColor((useWhite) ? Color.WHITE : mygray);
423: g.fillRect(0, bandStartY, this .getWidth(), bandEndY
424: - bandStartY);
425: }
426: useWhite = !useWhite;
427:
428: g.setColor(Color.BLACK);
429: // Write thicks between bandStartY and bandEndY...
430: i = bandStartY;
431: line = 0;
432: k = 1.0 / module;
433: oldi = -100;
434:
435: while (i < bandEndY) {
436:
437: if (i >= 0) {
438: if ((line % module) == 0) {
439: if (i - oldi > 20) {
440: String s = "" + (int) k;
441: if (isMillimeters)
442: s += "0";
443: if (isPixel)
444: s = "" + ((int) k * 50);
445:
446: if (bandEndY - i > 8) {
447: writeRotateString((Graphics2D) g,
448: 4, i, s);
449: }
450: //g.drawString(s ,1, i + g.getFontMetrics().getDescent());
451: oldi = i;
452: g.drawLine(16, i, 12, i);
453: } else {
454: g.drawLine(5, i, 10, i);
455: }
456:
457: } else {
458: if (module == 10 && (line % 5) != 0) {
459: g.drawLine(7, i, 8, i);
460: } else {
461: g.drawLine(6, i, 9, i);
462: }
463: }
464: }
465: line++;
466: k = line * (1.0 / module);
467: i = bandStartY
468: + (int) (convertUnitToPixel(k, unit) * zoomfactor);
469: }
470:
471: if (bandEndY > this .getHeight())
472: break;
473: }
474:
475: // Draw the lines on top of the page limit...
476: line = 1;
477: k = 1.0 / module;
478: oldi = y1;
479:
480: g.setColor(Color.BLACK);
481:
482: i = y1 - (int) (convertUnitToPixel(k, unit) * zoomfactor);
483: while (y1 > 0 && i > -10) {
484: if (i >= 0) {
485: if ((line % module) == 0) {
486: if (i - oldi > 20) {
487: String s = "" + (int) k;
488: if (isMillimeters)
489: s += "0";
490: if (isPixel)
491: s = "" + ((int) k * 50);
492:
493: int w = g.getFontMetrics().stringWidth(s);
494: writeRotateString((Graphics2D) g, 4, i, s);
495: //g.drawString(s ,1, i + g.getFontMetrics().getDescent());
496: oldi = i;
497: g.drawLine(16, i, 12, i);
498: } else {
499: g.drawLine(5, i, 10, i);
500: }
501:
502: } else {
503: if (module == 10 && (line % 5) != 0) {
504: g.drawLine(7, i, 8, i);
505: } else {
506: g.drawLine(6, i, 9, i);
507: }
508: }
509: }
510: line++;
511: k = line * (1.0 / module);
512: i = y1
513: - (int) (convertUnitToPixel(k, unit) * zoomfactor);
514: }
515:
516: for (i = 0; i < getGuideLines().size(); ++i) {
517: Integer pos = (Integer) getGuideLines().get(i);
518: int posI = pos.intValue();
519: // Calc posI....
520: posI = 10 + (int) (posI * zoomfactor)
521: - getJReportFrame().getHScroll();
522: g.drawImage(horizontalRuleStopIcon.getImage(), 7,
523: posI - 4, this );
524: }
525:
526: }
527: }
528:
529: public void writeRotateString(Graphics2D g2, int x, int yCenter,
530: String s) {
531:
532: java.awt.geom.Rectangle2D sb = g2.getFontMetrics()
533: .getStringBounds(s, g2);
534: int sw = (int) sb.getWidth();
535: int sh = (int) (sb.getHeight() / 2);
536:
537: //g2.drawString(s,x - sw/3, yCenter+sh/2);
538:
539: AffineTransform oldAr = g2.getTransform();
540:
541: int rotX = x;
542: int rotY = yCenter;
543:
544: AffineTransform at = g2.getTransform();
545: at.rotate(-Math.PI / 2.0, x, yCenter);
546: at.translate(-(sw / 2), sh);
547: //AffineTransform at = AffineTransform.getRotateInstance(-Math.PI/2.0, x, yCenter);
548: //AffineTransform at2 = AffineTransform.getTranslateInstance(-(sw/2),sh);
549: g2.setTransform(at);
550:
551: g2.drawString(s, x, yCenter);//s,x - (sw/2) , yCenter + sh);
552: g2.setTransform(oldAr);
553:
554: }
555:
556: /** Getter for property cursorPosition.
557: * @return Value of property cursorPosition.
558: *
559: */
560: public int getCursorPosition() {
561: return cursorPosition;
562: }
563:
564: /** Setter for property cursorPosition.
565: * @param cursorPosition New value of property cursorPosition.
566: *
567: */
568: public void setCursorPosition(int cursorPosition) {
569: Graphics g = this .getGraphics();
570: if (g == null)
571: return;
572: g.setXORMode(Color.WHITE);
573:
574: if (getType() == TYPE_HORIZONTAL) {
575: g.drawLine(this .cursorPosition, 0, this .cursorPosition,
576: this .getHeight());
577: this .cursorPosition = cursorPosition;
578: g.drawLine(this .cursorPosition, 0, this .cursorPosition,
579: this .getHeight());
580: } else {
581: g.drawLine(0, this .cursorPosition, this .getWidth(),
582: this .cursorPosition);
583: this .cursorPosition = cursorPosition;
584: g.drawLine(0, this .cursorPosition, this .getWidth(),
585: this .cursorPosition);
586: }
587:
588: g.setPaintMode();
589: }
590:
591: public JReportFrame getJReportFrame() {
592: return jReportFrame;
593: }
594:
595: public void setJReportFrame(JReportFrame jReportFrame) {
596: this .jReportFrame = jReportFrame;
597: }
598:
599: public int convertUnitToPixel(double value, double unit) {
600: if (unit == Unit.PIXEL)
601: return (int) value;
602: return (int) Unit.convertToPixels(value, unit);
603: }
604:
605: public int getType() {
606: return type;
607: }
608:
609: public void setType(int type) {
610: if (type != this .type) {
611: horizontalRuleStopIcon = new javax.swing.ImageIcon(
612: getClass().getResource(
613: "/it/businesslogic/ireport/icons/toolbars/rulestop"
614: + ((type == TYPE_VERTICAL) ? "v"
615: : "") + ".png"));
616: this .type = type;
617: }
618: }
619:
620: public void panelMousePressed(java.awt.event.MouseEvent evt) {
621:
622: // Look for an existing gridline....
623: int currentLine = -1;
624: for (int i = 0; i < getGuideLines().size(); ++i) {
625: Integer pos = (Integer) getGuideLines().get(i);
626: int posI = pos.intValue();
627: // Calc posI....
628: int scroll = (getType() == TYPE_HORIZONTAL) ? getJReportFrame()
629: .getHScroll()
630: : getJReportFrame().getVScroll();
631: posI = 10
632: + (int) (posI * getJReportFrame().getZoomFactor())
633: - scroll;
634:
635: int mousePos = (getType() == TYPE_HORIZONTAL) ? evt.getX()
636: : evt.getY();
637:
638: if (mousePos > posI - 3 && mousePos < posI + 3) {
639: currentLine = posI;
640: getGuideLines().remove(i);
641: break;
642: }
643: }
644:
645: savedImage = ((java.awt.image.BufferedImage) this .createImage(
646: this .getWidth(), this .getHeight()));
647: Graphics2D savedGraphics = savedImage.createGraphics();
648: this .paint(savedGraphics);
649:
650: if (getType() == TYPE_HORIZONTAL)
651: this .getGraphics().drawImage(
652: horizontalRuleStopIcon.getImage(), evt.getX() - 4,
653: 7, this );
654: else
655: this .getGraphics().drawImage(
656: horizontalRuleStopIcon.getImage(), 7,
657: evt.getY() - 4, this );
658:
659: lastTempGuidePosition = (getType() == TYPE_HORIZONTAL) ? evt
660: .getX() : evt.getY();
661: Graphics2D jrfGraphics = (Graphics2D) this .getJReportFrame()
662: .getReportPanel().getGraphics();
663: Stroke oldStroke = jrfGraphics.getStroke();
664: jrfGraphics.setXORMode(java.awt.Color.YELLOW);
665: jrfGraphics.setStroke(getDottedStroke());
666: if (lastTempGuidePosition >= 0) {
667: if (getType() == TYPE_HORIZONTAL)
668: jrfGraphics.drawLine(currentLine, 0, currentLine, this
669: .getJReportFrame().getHeight());
670: else
671: jrfGraphics.drawLine(0, currentLine, this
672: .getJReportFrame().getWidth(), currentLine);
673: }
674: if (getType() == TYPE_HORIZONTAL)
675: jrfGraphics.drawLine(lastTempGuidePosition, 0,
676: lastTempGuidePosition, this .getJReportFrame()
677: .getHeight());
678: else
679: jrfGraphics.drawLine(0, lastTempGuidePosition, this
680: .getJReportFrame().getWidth(),
681: lastTempGuidePosition);
682: jrfGraphics.setPaintMode();
683: jrfGraphics.setStroke(oldStroke);
684: }
685:
686: public void panelMouseReleased(java.awt.event.MouseEvent evt) {
687:
688: this .getGraphics().drawImage(savedImage, 0, 0, this );
689:
690: if (getType() == TYPE_HORIZONTAL) {
691: if (evt.getX() > 0 && evt.getX() < this .getWidth()) {
692: int newPosition = getJReportFrame().getLogicalDim(
693: (int) evt.getX()
694: + getJReportFrame().getHScroll() - 10);
695: this .getGuideLines().add(new Integer(newPosition));
696: this .repaint();
697: this .getJReportFrame().repaint();
698: }
699: } else {
700: if (evt.getY() > 0 && evt.getY() < this .getHeight()) {
701: int newPosition = getJReportFrame().getLogicalDim(
702: (int) evt.getY()
703: + getJReportFrame().getVScroll() - 10);
704: this .getGuideLines().add(new Integer(newPosition));
705: this .repaint();
706: this .getJReportFrame().repaint();
707: }
708: }
709: }
710:
711: public void panelMouseDragged(MouseEvent e) {
712:
713: this .getGraphics().drawImage(savedImage, 0, 0, this );
714:
715: if (getType() == TYPE_HORIZONTAL) {
716: this .getGraphics().drawImage(
717: horizontalRuleStopIcon.getImage(), e.getX() - 4, 7,
718: this );
719:
720: } else {
721: this .getGraphics().drawImage(
722: horizontalRuleStopIcon.getImage(), 7, e.getY() - 4,
723: this );
724: }
725:
726: Graphics2D jrfGraphics = (Graphics2D) this .getJReportFrame()
727: .getReportPanel().getGraphics();
728: Stroke oldStroke = jrfGraphics.getStroke();
729: jrfGraphics.setXORMode(java.awt.Color.YELLOW);
730: jrfGraphics.setStroke(getDottedStroke());
731: if (lastTempGuidePosition >= 0) {
732: if (getType() == TYPE_HORIZONTAL)
733: jrfGraphics.drawLine(lastTempGuidePosition, 0,
734: lastTempGuidePosition, this .getJReportFrame()
735: .getHeight());
736: else
737: jrfGraphics.drawLine(0, lastTempGuidePosition, this
738: .getJReportFrame().getWidth(),
739: lastTempGuidePosition);
740: }
741: lastTempGuidePosition = (getType() == TYPE_HORIZONTAL) ? e
742: .getX() : e.getY();
743: if (getType() == TYPE_HORIZONTAL)
744: jrfGraphics.drawLine(lastTempGuidePosition, 0,
745: lastTempGuidePosition, this .getJReportFrame()
746: .getHeight());
747: else
748: jrfGraphics.drawLine(0, lastTempGuidePosition, this
749: .getJReportFrame().getWidth(),
750: lastTempGuidePosition);
751: jrfGraphics.setPaintMode();
752: jrfGraphics.setStroke(oldStroke);
753: }
754:
755: public void panelMouseMoved(MouseEvent e) {
756: setCursorPosition(getType() == TYPE_HORIZONTAL ? e.getX() : e
757: .getY());
758: }
759:
760: public boolean isDragging() {
761: return dragging;
762: }
763:
764: public void setDragging(boolean dragging) {
765: this .dragging = dragging;
766: }
767:
768: public java.util.List getGuideLines() {
769: return guideLines;
770: }
771:
772: public void setGuideLines(java.util.List guideLines) {
773: this .guideLines = guideLines;
774: }
775:
776: public Stroke getDottedStroke() {
777: return dottedStroke;
778: }
779:
780: public void setDottedStroke(Stroke dottedStroke) {
781: this.dottedStroke = dottedStroke;
782: }
783: }
|