Update of /cvsroot/tn5250j/tn5250j/src/org/tn5250j
In directory sc8-pr-cvs1:/tmp/cvs-serv19201/src/org/tn5250j
Modified Files:
Gui5250.java RubberBand.java Screen5250.java
Log Message:
Update for the selectings areas
Index: Gui5250.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/Gui5250.java,v
retrieving revision 1.53
retrieving revision 1.54
diff -C2 -d -r1.53 -r1.54
*** Gui5250.java 1 Dec 2003 06:45:53 -0000 1.53
--- Gui5250.java 5 Dec 2003 07:07:12 -0000 1.54
***************
*** 699,702 ****
--- 699,706 ----
screen.paintComponent3(g);
+ if (rubberband.isAreaSelected() && !rubberband.isDragging()) {
+ rubberband.erase();
+ rubberband.draw();
+ }
keyPad.repaint();
Index: RubberBand.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/RubberBand.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** RubberBand.java 10 Mar 2003 20:08:53 -0000 1.3
--- RubberBand.java 5 Dec 2003 07:07:13 -0000 1.4
***************
*** 1,239 ****
! package org.tn5250j;
! /**
! * Title: tn5250J
! * Copyright: Copyright (c) 2001
! * Company:
! * @author Kenneth J. Pouncey
! * @version 0.4
! *
! * Description:
! *
! * This program is free software; you can redistribute it and/or modify
! * it under the terms of the GNU General Public License as published by
! * the Free Software Foundation; either version 2, or (at your option)
! * any later version.
! *
! * This program is distributed in the hope that it will be useful,
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! * GNU General Public License for more details.
! *
! * You should have received a copy of the GNU General Public License
! * along with this software; see the file COPYING. If not, write to
! * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
! * Boston, MA 02111-1307 USA
! *
! */
!
! import java.awt.*;
! import java.awt.event.*;
! import javax.swing.SwingUtilities;
!
! public abstract class RubberBand {
! private RubberBandCanvasIF canvas;
! protected Point startPoint;
! protected Point endPoint;
! private boolean eraseSomething = false;
! private boolean isSomethingBounded = false;
!
! private class MouseHandler extends MouseAdapter
! {
! public void mousePressed(MouseEvent e) {
! if (!SwingUtilities.isRightMouseButton(e)) {
! if (!isSomethingBounded)
! start(canvas.translateStart(e.getPoint()));
! else {
! if (isSomethingBounded) {
! erase();
! notifyRubberBandCanvas();
! reset();
! start(canvas.translateStart(e.getPoint()));
! }
! }
! }
!
! // System.out.println("mouse pressed rb");
! }
!
! public void mouseReleased(MouseEvent e) {
! erase();
! }
!
! }
!
! private class MouseMotionHandler extends MouseMotionAdapter {
!
! public void mouseDragged(MouseEvent e) {
!
! if(!SwingUtilities.isRightMouseButton(e) && getCanvas().canDrawRubberBand(RubberBand.this)) {
!
! erase();
! stop(canvas.translateEnd(e.getPoint()));
! notifyRubberBandCanvas();
! draw();
! notifyRubberBandCanvas();
! }
! }
!
! }
!
! public RubberBand(RubberBandCanvasIF c) {
! super();
! setCanvas(c);
! getCanvas().addMouseListener(new MouseHandler());
! getCanvas().addMouseMotionListener(new MouseMotionHandler());
! }
!
! protected void draw() {
! // Graphics g = getCanvas().getGraphics();
! Graphics g = getCanvas().getDrawingGraphics();
!
! if(g != null){
! try {
! if(getCanvas().canDrawRubberBand(this)) {
! g.setXORMode(canvas.getBackground());
! drawRubberBand(g);
! // we have drawn something, set the flag to indicate this
! setEraseSomething(true);
! }
! }
! finally {
! g.dispose();
! }
! }
! }
!
! protected abstract void drawBoundingShape(Graphics g,int startx, int starty, int width, int height);
!
! protected void drawRubberBand(Graphics g) {
!
! if((getEndPoint().x > getStartPoint().x) && (getEndPoint().y > getStartPoint().y)) {
! drawBoundingShape(g,getStartPoint().x,getStartPoint().y,getEndPoint().x-getStartPoint().x,getEndPoint().y-getStartPoint().y);
! }
!
! else if((getEndPoint().x < getStartPoint().x) && (getEndPoint().y < getStartPoint().y)) {
! drawBoundingShape(g,getEndPoint().x,getEndPoint().y,getStartPoint().x-getEndPoint().x,getStartPoint().y-getEndPoint().y);
! }
!
! else if((getEndPoint().x > getStartPoint().x) && (getEndPoint().y < getStartPoint().y)) {
! drawBoundingShape(g,getStartPoint().x,getEndPoint().y,getEndPoint().x-getStartPoint().x,getStartPoint().y-getEndPoint().y);
! }
!
! else if((getEndPoint().x < getStartPoint().x) && (getEndPoint().y > getStartPoint().y)) {
! drawBoundingShape(g,getEndPoint().x,getStartPoint().y,getStartPoint().x-getEndPoint().x,getEndPoint().y-getStartPoint().y);
! }
! isSomethingBounded = true;
!
! }
!
! protected void erase() {
!
! if(getEraseSomething()) {
! draw();
! setEraseSomething(false);
! }
!
! }
!
! public final RubberBandCanvasIF getCanvas() {
! return this.canvas;
! }
!
! protected Point getEndPoint() {
! if(this.endPoint == null) {
! setEndPoint(new Point(0,0));
! }
! return this.endPoint;
! }
!
! protected Point getStartPoint() {
!
! if(this.startPoint == null) {
! setStartPoint(new Point(0,0));
! }
! return this.startPoint;
!
! }
!
! protected final boolean getEraseSomething() {
! return this.eraseSomething;
! }
!
! protected void notifyRubberBandCanvas() {
!
! int startX, startY, endX, endY;
!
! if(getStartPoint().x < getEndPoint().x) {
! startX = getStartPoint().x;
! endX = getEndPoint().x;
! }
! else {
! startX = getEndPoint().x;
! endX = getStartPoint().x;
! }
! if(getStartPoint().y < getEndPoint().y) {
! startY = getStartPoint().y;
! endY = getEndPoint().y;
! }
! else {
! startY = getEndPoint().y;
! endY = getStartPoint().y;
! }
!
! getCanvas().areaBounded(this,startX, startY, endX, endY);
!
! }
!
! public final void setCanvas(RubberBandCanvasIF c) {
! this.canvas = c;
! }
!
! protected final void setEndPoint(Point newValue){
! this.endPoint = newValue;
! }
!
! protected final void setEraseSomething(boolean newValue) {
! this.eraseSomething = newValue;
! }
!
! protected final void setStartPoint(Point newValue) {
! this.startPoint = newValue;
! if (startPoint == null)
! endPoint = null;
!
! }
!
! protected void start(Point p) {
! setEndPoint(p);
! setStartPoint(p);
! // System.out.println("start " + startPoint + " end " + endPoint);
! }
!
! protected void stop(Point p) {
!
! if(p.x < 0) {
! p.x = 0;
! }
!
! if(p.y < 0) {
! p.y = 0;
! }
!
! setEndPoint(p);
! // System.out.println("stop " + startPoint + " end " + endPoint);
!
! }
!
! protected void reset() {
! erase();
! setStartPoint(null);
! setEndPoint(null);
! isSomethingBounded = false;
!
! }
!
! protected final boolean isAreaSelected() {
! return isSomethingBounded;
! }
!
}
--- 1,256 ----
! package org.tn5250j;
! /**
! * Title: tn5250J
! * Copyright: Copyright (c) 2001
! * Company:
! * @author Kenneth J. Pouncey
! * @version 0.4
! *
! * Description:
! *
! * This program is free software; you can redistribute it and/or modify
! * it under the terms of the GNU General Public License as published by
! * the Free Software Foundation; either version 2, or (at your option)
! * any later version.
! *
! * This program is distributed in the hope that it will be useful,
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! * GNU General Public License for more details.
! *
! * You should have received a copy of the GNU General Public License
! * along with this software; see the file COPYING. If not, write to
! * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
! * Boston, MA 02111-1307 USA
! *
! */
!
! import java.awt.*;
! import java.awt.event.*;
! import javax.swing.SwingUtilities;
!
! public abstract class RubberBand {
! private RubberBandCanvasIF canvas;
! protected Point startPoint;
! protected Point endPoint;
! private boolean eraseSomething = false;
! private boolean isSomethingBounded = false;
! private boolean isDragging = false;
!
! private class MouseHandler extends MouseAdapter
! {
! public void mousePressed(MouseEvent e) {
! if (!SwingUtilities.isRightMouseButton(e)) {
! if (!isSomethingBounded)
! start(canvas.translateStart(e.getPoint()));
! else {
! // if (isSomethingBounded) {
! // erase();
! // notifyRubberBandCanvas();
! // reset();
! // start(canvas.translateStart(e.getPoint()));
! // }
! }
! }
!
! // System.out.println("mouse pressed rb");
! }
!
! public void mouseReleased(MouseEvent e) {
! isDragging = false;
! }
!
! }
!
! private class MouseMotionHandler extends MouseMotionAdapter {
!
! public void mouseDragged(MouseEvent e) {
!
! if(!SwingUtilities.isRightMouseButton(e) && getCanvas().canDrawRubberBand(RubberBand.this)) {
!
! // if (!isDragging) {
! //
! // if (isSomethingBounded) {
! // erase();
! // notifyRubberBandCanvas();
! // reset();
! // start(canvas.translateStart(e.getPoint()));
! // }
! //
! //
! // }
! isDragging = true;
! erase();
! stop(canvas.translateEnd(e.getPoint()));
! notifyRubberBandCanvas();
! draw();
! notifyRubberBandCanvas();
! }
! }
!
! }
!
! public boolean isDragging() {
! return isDragging;
! }
!
! public RubberBand(RubberBandCanvasIF c) {
! super();
! setCanvas(c);
! getCanvas().addMouseListener(new MouseHandler());
! getCanvas().addMouseMotionListener(new MouseMotionHandler());
! }
!
! protected void draw() {
! // Graphics g = getCanvas().getGraphics();
! Graphics g = getCanvas().getDrawingGraphics();
!
! if(g != null){
! try {
! if(getCanvas().canDrawRubberBand(this)) {
! g.setXORMode(canvas.getBackground());
! drawRubberBand(g);
! // we have drawn something, set the flag to indicate this
! setEraseSomething(true);
! }
! }
! finally {
! g.dispose();
! }
! }
! }
!
! protected abstract void drawBoundingShape(Graphics g,int startx, int starty, int width, int height);
!
! protected void drawRubberBand(Graphics g) {
!
! if((getEndPoint().x > getStartPoint().x) && (getEndPoint().y > getStartPoint().y)) {
! drawBoundingShape(g,getStartPoint().x,getStartPoint().y,getEndPoint().x-getStartPoint().x,getEndPoint().y-getStartPoint().y);
! }
!
! else if((getEndPoint().x < getStartPoint().x) && (getEndPoint().y < getStartPoint().y)) {
! drawBoundingShape(g,getEndPoint().x,getEndPoint().y,getStartPoint().x-getEndPoint().x,getStartPoint().y-getEndPoint().y);
! }
!
! else if((getEndPoint().x > getStartPoint().x) && (getEndPoint().y < getStartPoint().y)) {
! drawBoundingShape(g,getStartPoint().x,getEndPoint().y,getEndPoint().x-getStartPoint().x,getStartPoint().y-getEndPoint().y);
! }
!
! else if((getEndPoint().x < getStartPoint().x) && (getEndPoint().y > getStartPoint().y)) {
! drawBoundingShape(g,getEndPoint().x,getStartPoint().y,getStartPoint().x-getEndPoint().x,getEndPoint().y-getStartPoint().y);
! }
! isSomethingBounded = true;
!
! }
!
! protected void erase() {
!
! if(getEraseSomething()) {
! draw();
! setEraseSomething(false);
! }
!
! }
!
! public final RubberBandCanvasIF getCanvas() {
! return this.canvas;
! }
!
! protected Point getEndPoint() {
! if(this.endPoint == null) {
! setEndPoint(new Point(0,0));
! }
! return this.endPoint;
! }
!
! protected Point getStartPoint() {
!
! if(this.startPoint == null) {
! setStartPoint(new Point(0,0));
! }
! return this.startPoint;
!
! }
!
! protected final boolean getEraseSomething() {
! return this.eraseSomething;
! }
!
! protected void notifyRubberBandCanvas() {
!
! int startX, startY, endX, endY;
!
! if(getStartPoint().x < getEndPoint().x) {
! startX = getStartPoint().x;
! endX = getEndPoint().x;
! }
! else {
! startX = getEndPoint().x;
! endX = getStartPoint().x;
! }
! if(getStartPoint().y < getEndPoint().y) {
! startY = getStartPoint().y;
! endY = getEndPoint().y;
! }
! else {
! startY = getEndPoint().y;
! endY = getStartPoint().y;
! }
!
! getCanvas().areaBounded(this,startX, startY, endX, endY);
!
! }
!
! public final void setCanvas(RubberBandCanvasIF c) {
! this.canvas = c;
! }
!
! protected final void setEndPoint(Point newValue){
! this.endPoint = newValue;
! }
!
! protected final void setEraseSomething(boolean newValue) {
! this.eraseSomething = newValue;
! }
!
! protected final void setStartPoint(Point newValue) {
! this.startPoint = newValue;
! if (startPoint == null)
! endPoint = null;
!
! }
!
! protected void start(Point p) {
! setEndPoint(p);
! setStartPoint(p);
! // System.out.println("start " + startPoint + " end " + endPoint);
! }
!
! protected void stop(Point p) {
!
! if(p.x < 0) {
! p.x = 0;
! }
!
! if(p.y < 0) {
! p.y = 0;
! }
!
! setEndPoint(p);
! // System.out.println("stop " + startPoint + " end " + endPoint);
!
! }
!
! protected void reset() {
! erase();
! setStartPoint(null);
! setEndPoint(null);
! isSomethingBounded = false;
!
! }
!
! protected final boolean isAreaSelected() {
! return isSomethingBounded;
! }
!
}
Index: Screen5250.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/Screen5250.java,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -d -r1.40 -r1.41
*** Screen5250.java 25 Nov 2003 15:10:10 -0000 1.40
--- Screen5250.java 5 Dec 2003 07:07:13 -0000 1.41
***************
*** 1177,1184 ****
}
else {
- if (gui.rubberband.isAreaSelected()) {
- gui.rubberband.reset();
- gui.repaint();
- }
goto_XY(pos);
--- 1177,1180 ----
***************
*** 4114,4117 ****
--- 4110,4118 ----
}
+ // check for selected area and erase it before updating screen
+ if (gui.rubberband != null && gui.rubberband.isAreaSelected()) {
+ gui.rubberband.erase();
+ }
+
if (bi == null || gg2d == null) {
if (bi == null)
***************
*** 4143,4146 ****
--- 4144,4152 ----
if (gui.isVisible()) {
if (height > 0 && width > 0) {
+
+ // We now redraw the selected area rectangle.
+ if (gui.rubberband != null && gui.rubberband.isAreaSelected()) {
+ gui.rubberband.draw();
+ }
if (!fullRepaint)
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.