Make first real commit: copy of CaRMetal 4.2.8

This commit is contained in:
Glen Whitney 2018-09-04 22:51:42 -04:00
parent 002acfc88e
commit c312811084
1120 changed files with 226843 additions and 1 deletions

View file

@ -0,0 +1,210 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
// file: Hider.java
import java.awt.Cursor;
import java.awt.event.MouseEvent;
import java.util.Enumeration;
import rene.zirkel.Zirkel;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.construction.Construction;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.ConstructionObject;
import rene.zirkel.objects.ExpressionObject;
import rene.zirkel.objects.MoveableObject;
import rene.zirkel.objects.TextObject;
import rene.zirkel.objects.UserFunctionObject;
/**
* @author Rene Werkzeug zum Zoomen des Fensters und zum Verschieben.
* Verschieben funktioniert im Zentrum des Fensters.
*/
public class ZoomerTool extends ObjectConstructor {
boolean Dragging = false, Zoom = false;
double X, Y, W, X0, Y0;
ObjectConstructor OC;
public static void initNonDraggableObjects(final Construction c) {
final Enumeration en = c.elements();
while (en.hasMoreElements()) {
final ConstructionObject o = (ConstructionObject) en.nextElement();
if ((o instanceof TextObject) || (o instanceof ExpressionObject)
|| (o instanceof UserFunctionObject)) {
final MoveableObject mo = (MoveableObject) o;
mo.startDrag(0, 0);
}
}
}
public static void shiftNonDraggableObjectsBy(final Construction c,
final double dx, final double dy) {
final Enumeration en = c.elements();
while (en.hasMoreElements()) {
final ConstructionObject o = (ConstructionObject) en.nextElement();
if ((o instanceof TextObject) || (o instanceof ExpressionObject)
|| (o instanceof UserFunctionObject)) {
final MoveableObject mo = (MoveableObject) o;
mo.dragTo(dx, dy);
}
// else if (!o.isKeepClose()) {
//
// System.out.println("dx="+dx);
// o.setcOffset(o.xcOffset()+2*dx, o.ycOffset()+2*dy);
//
// // C.setXYW(C.getX()+dx*C.getW(), C.getY()+dy*C.getW(),
// C.getW());
//
// };
}
}
public static void zoomNonDraggableObjectsBy(final Construction c,
final double f) {
final Enumeration en = c.elements();
while (en.hasMoreElements()) {
final ConstructionObject o = (ConstructionObject) en.nextElement();
if ((o instanceof TextObject) || (o instanceof ExpressionObject)
|| (o instanceof UserFunctionObject)) {
final MoveableObject mo = (MoveableObject) o;
mo.move(c.getX() + (mo.getOldX() - c.getX()) * f, c.getY()
+ (mo.getOldY() - c.getY()) * f);
}
}
}
public ZoomerTool() {
super();
}
public ZoomerTool(final ObjectConstructor oc, final MouseEvent e,
final ZirkelCanvas zc) {
super();
OC = oc;
X0 = zc.x(e.getX());
Y0 = zc.y(e.getY());
final Construction c = zc.getConstruction();
X = c.getX();
Y = c.getY();
W = c.getW();
Zoom = false;
zc.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
Dragging = true;
initNonDraggableObjects(c);
}
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
X0 = zc.x(e.getX());
Y0 = zc.y(e.getY());
final Construction c = zc.getConstruction();
X = c.getX();
Y = c.getY();
W = c.getW();
Zoom = (Math.abs(X - X0) > W / 4 || Math.abs(Y - Y0) > W / 4);
if (!Zoom) {
zc.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
}
Dragging = true;
OC = null;
initNonDraggableObjects(c);
}
@Override
public void mouseDragged(final MouseEvent e, final ZirkelCanvas zc) {
if (!Dragging) {
return;
}
final Construction c = zc.getConstruction();
c.setXYW(X, Y, W);
zc.recompute();
final double x = zc.x(e.getX()), y = zc.y(e.getY());
if (Zoom) {
final double f = Math.sqrt((X0 - X) * (X0 - X) + (Y0 - Y)
* (Y0 - Y))
/ Math.sqrt((x - X) * (x - X) + (y - Y) * (y - Y));
c.setXYW(X, Y, f * W);
zoomNonDraggableObjectsBy(c, f);
} else {
c.setXYW(X - (x - X0), Y - (y - Y0), W);
shiftNonDraggableObjectsBy(c, X0 - x, Y0 - y);
}
zc.recompute();
zc.validate();
zc.repaint();
}
@Override
public void mouseReleased(final MouseEvent e, final ZirkelCanvas zc) {
Dragging = Zoom = false;
zc.setCursor(Cursor.getDefaultCursor());
zc.recompute();
zc.validate();
zc.repaint();
if (OC != null) {
zc.setTool(OC);
}
}
@Override
public void showStatus(final ZirkelCanvas zc) {
zc.showStatus(Zirkel.name("message.zoom"));
}
@Override
public void reset(final ZirkelCanvas zc) {
zc.clearSelected();
zc.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
Zoom = Dragging = false;
}
@Override
public void invalidate(final ZirkelCanvas zc) {
zc.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean flag) {
X0 = zc.x(e.getX());
Y0 = zc.y(e.getY());
final Construction c = zc.getConstruction();
X = c.getX();
Y = c.getY();
W = c.getW();
Zoom = (Math.abs(X - X0) > W / 4 || Math.abs(Y - Y0) > W / 4);
if (!Zoom) {
zc.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
} else {
zc.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
}
@Override
public boolean useSmartBoard() {
return false;
}
}

View file

@ -0,0 +1,160 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
import eric.animations.AnimationPanel;
import java.awt.event.MouseEvent;
import java.util.Enumeration;
import java.util.Vector;
import rene.util.xml.XmlWriter;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.construction.Selector;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.CircleObject;
import rene.zirkel.objects.ConstructionObject;
import rene.zirkel.objects.PointObject;
import rene.zirkel.objects.PrimitiveCircleObject;
import rene.zirkel.objects.SegmentObject;
/**
* Animator is a class to animate a point along a sequence of segments and/or
* circles. The animation may either go back and forth or always in the same
* direction. Shift-Click schaltet whrend der Animation um.
*
* @author Rene
*
*/
public class AnimatorTool extends ObjectConstructor implements Runnable,
Selector {
PointObject P;
ZirkelCanvas ZC;
boolean Running=false, Interactive=true, Complete=false;
boolean Negative=false;
boolean Original=false;
double Delay=50;
public AnimatorTool() {
P=null;
}
public AnimatorTool(final PointObject p, final Vector v,
final ZirkelCanvas zc, final boolean negative,
final boolean original, final String delay) {
P=p;
if (!P.moveable()) {
return;
}
final Enumeration e=v.elements();
while (e.hasMoreElements()) {
final ConstructionObject o=zc.getConstruction().find(
(String) e.nextElement());
if (!(o instanceof SegmentObject
||o instanceof PrimitiveCircleObject||o instanceof PointObject)) {
return;
}
}
Stopped=false;
ZC=zc;
Complete=true;
Negative=negative;
Original=original;
try {
Delay=50;
Delay=new Double(delay).doubleValue();
} catch (final Exception ex) {
}
new Thread(this).start();
}
public void setInteractive(final boolean flag) {
Interactive=flag;
}
public boolean isAdmissible(final ZirkelCanvas zc,
final ConstructionObject o) {
if ((o instanceof CircleObject)&&((CircleObject) o).getP2()==P) {
return true;
}
if (zc.depends(o, P)) {
return false;
}
return true;
}
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
ConstructionObject o=zc.selectAnimationObject(e.getX(), e.getY());
if (o!=null) {
if (zc.isAnimated(o)) {
o.setSelected(false);
zc.removeAnimation(o);
} else {
o.setSelected(true);
zc.addAnimation(o);
}
}
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean simple) {
zc.indicateAnimationObjects(e.getX(), e.getY());
}
@Override
public synchronized void reset(final ZirkelCanvas zc) {
zc.selectAnimationPoints();
}
@Override
public void showStatus(final ZirkelCanvas zc) {
if (P==null) {
zc.showStatus(Global.name("message.animator.point"));
} else if (!Complete) {
zc.showStatus(Global.name("message.animator.segment"));
} else {
zc.showStatus(Global.name("message.animator.running"));
}
}
public void save(final XmlWriter xml) {
ZC.getAnimations().printArgs(xml);
}
boolean Stopped=false;
public void run() {
}
@Override
public synchronized void invalidate(final ZirkelCanvas zc) {
Stopped=true;
}
@Override
public boolean useSmartBoard() {
return false;
}
}

View file

@ -0,0 +1,111 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
// file: Binder.java
import java.awt.event.MouseEvent;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.construction.Selector;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.ConstructionObject;
import rene.zirkel.objects.InsideObject;
import rene.zirkel.objects.PointObject;
import rene.zirkel.objects.PointonObject;
public class BinderTool extends ObjectConstructor implements Selector {
ObjectConstructor OC;
PointObject P;
public BinderTool(final ZirkelCanvas zc, final PointObject p,
final ObjectConstructor oc) {
P=p;
OC=oc;
P.setSelected(true);
zc.repaint();
}
boolean Control, Shift;
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
Control=e.isControlDown();
Shift=e.isShiftDown();
final ConstructionObject o=zc.selectWithSelector(e.getX(), e.getY(),this);
setConstructionObject(o, zc);
}
@Override
public void setConstructionObject(ConstructionObject obj, ZirkelCanvas zc) {
if (obj==null) {
return;
}
if (Control&&!(obj instanceof InsideObject)) {
return;
}
if (zc.getConstruction().dependsOn(obj, P)) {
return;
}
P.setBound(obj.getName());
P.setUseAlpha(!Shift);
if(Control) P.setInside(true);
zc.getConstruction().updateCircleDep();
zc.repaint();
reset(zc);
eric.bar.JPropertiesBar.EditObject(P, false, false);
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean simple) {
Control=e.isControlDown();
zc.indicateWithSelector(e.getX(), e.getY(), this);
}
public boolean isAdmissible(final ZirkelCanvas zc,
final ConstructionObject o) {
if ((o instanceof InsideObject||o instanceof PointonObject)
&&!zc.getConstruction().dependsOn(o, P)) {
return true;
}
return false;
}
@Override
public void showStatus(final ZirkelCanvas zc) {
zc.showStatus(Global.name("message.bindpoint"));
}
@Override
public void reset(final ZirkelCanvas zc) {
super.reset(zc);
zc.setTool(OC);
zc.validate();
zc.repaint();
}
@Override
public boolean useSmartBoard() {
return false;
}
}

View file

@ -0,0 +1,184 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
import java.awt.event.MouseEvent;
import java.util.Enumeration;
import rene.util.MyVector;
import rene.util.xml.XmlWriter;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.ConstructionObject;
public class BreakpointAnimator extends ObjectConstructor implements Runnable {
MyVector Breaks; // Vector of breakpoints
ZirkelCanvas ZC;
boolean Loop = false;
public BreakpointAnimator() {
Breaks = new MyVector();
}
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
zc.y(e.getY());
ZC = zc;
if (Running) {
if (e.isShiftDown())
Loop = !Loop;
else {
Stopped = true;
zc.paintUntil(null);
}
} else {
reset(zc);
}
}
@Override
public synchronized void reset(final ZirkelCanvas zc) {
super.reset(zc);
ZC = zc;
showStatus(zc);
if (Running) {
Stopped = true;
zc.paintUntil(null);
} else {
Stopped = false;
new Thread(this).start();
}
}
@Override
public void showStatus(final ZirkelCanvas zc) {
zc.showStatus(Global.name("message.animatebreak"));
}
public void save(final XmlWriter xml) {
xml.startTagStart("AnimateBreakpoints");
xml.printArg("time", "" + SleepTime);
if (Loop)
xml.printArg("loop", "true");
xml.finishTagNewLine();
}
boolean Running = false, Stopped = false;
long SleepTime = 1024;
public void run() {
ZC.getConstruction().setOriginalOrder(true);
Running = true;
Breaks = new MyVector();
final Enumeration e = ZC.getConstruction().elements();
while (e.hasMoreElements()) {
final ConstructionObject o = (ConstructionObject) e.nextElement();
if (o.isBreak())
Breaks.addElement(o);
}
final Object H[] = Breaks.getArray();
int N = 0;
if (Breaks.size() == 0) {
Running = false;
ZC.getConstruction().setOriginalOrder(false);
return;
}
ConstructionObject O = (ConstructionObject) H[0];
boolean forward = true;
while (!Stopped) {
if (!Stopped)
ZC.paintUntil(O);
try {
Thread.sleep(SleepTime);
} catch (final Exception ex) {
}
if (Stopped)
break;
if (Loop) {
if (forward) {
if (N < Breaks.size() - 1) {
N++;
O = (ConstructionObject) H[N];
} else if (N == Breaks.size() - 1) {
N++;
forward = false;
O = null;
}
} else {
if (N > 0) {
N--;
O = (ConstructionObject) H[N];
} else {
N = 1;
O = (ConstructionObject) H[N];
forward = true;
}
}
} else {
if (N < Breaks.size() - 1) {
N++;
O = (ConstructionObject) H[N];
} else if (N == Breaks.size() - 1) {
N++;
O = null;
} else {
N = 0;
O = (ConstructionObject) H[N];
}
}
}
Running = false;
ZC.getConstruction().setOriginalOrder(false);
}
@Override
public synchronized void invalidate(final ZirkelCanvas zc) {
Stopped = true;
ZC.paintUntil(null);
}
@Override
public boolean useSmartBoard() {
return false;
}
public void increaseSpeed() {
if (SleepTime >= 32000)
return;
SleepTime = SleepTime * 2;
}
public void decreaseSpeed() {
if (SleepTime == 1)
return;
SleepTime = SleepTime / 2;
}
public void setSpeed(final long delay) {
SleepTime = delay;
}
public void setLoop(final boolean flag) {
Loop = flag;
}
}

View file

@ -0,0 +1,73 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
// file: SetParameter.java
import java.awt.event.MouseEvent;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.ConstructionObject;
public class DefineJobTool extends ObjectConstructor {
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
zc.y(e.getY());
final ConstructionObject o=zc.selectObject(e.getX(), e.getY());
if (o==null) {
return;
}
if (o.selected()) {
o.setSelected(false);
zc.job_removeTarget(o);
} else {
o.setSelected(true);
zc.job_addTarget(o);
}
zc.job_setTargetsField();
zc.repaint();
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean simple) {
zc.indicateObjects(e.getX(), e.getY());
}
@Override
public void reset(final ZirkelCanvas zc) {
super.reset(zc);
zc.clearSelected();
showStatus(zc);
}
@Override
public void showStatus(final ZirkelCanvas zc) {
zc.showStatus(""); //otherwise, the ZTextFiledAndLabel are invisible on ZDialog windows when user ask them twice
zc.showStatus(Global.name("message.savejob.second"));
}
@Override
public boolean useSmartBoard() {
return false;
}
}

View file

@ -0,0 +1,75 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
// file: Hider.java
import eric.bar.JProperties;
import eric.bar.JPropertiesBar;
import java.awt.event.MouseEvent;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.ConstructionObject;
public class DeleteTool extends ObjectConstructor {
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
final ConstructionObject o=zc.selectObject(e.getX(), e.getY());
setConstructionObject(o, zc);
}
@Override
public void setConstructionObject(ConstructionObject obj, ZirkelCanvas zc) {
if (obj!=null) {
//to prevent deleting axis in 3D mode
// /*A finir
if(zc.is3D() &&
(obj.getName().equals("O") || obj.getName().equals("X")
|| obj.getName().equals("Y")
|| obj.getName().equals("Z")
|| obj.getName().equals("s6") || obj.getName().equals("s7") || obj.getName().equals("s8"))){
return;
}
// */
zc.delete(obj);
zc.repaint();
if(JPropertiesBar.isBarVisible() && JProperties.getObject() == obj){
JProperties.setObject(null);
JPropertiesBar.clearme();
}
}
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean simple) {
zc.indicateObjects(e.getX(), e.getY());
// zc.paintToolIcon("delete");
}
@Override
public void showStatus(final ZirkelCanvas zc) {
zc.showStatus(Global.name("message.delete", "Delete: Select an object!"));
}
}

View file

@ -0,0 +1,76 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
// file: Hider.java
import java.awt.event.MouseEvent;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.graphics.Drawing;
public class DrawerTool extends ObjectConstructor {
Drawing D;
boolean Dragging = false;
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
final double x = zc.x(e.getX()), y = zc.y(e.getY());
D = new Drawing();
D.addXY(x, y);
Dragging = true;
zc.addDrawing(D);
D.setColor(zc.getDefaultColor());
}
@Override
public void mouseDragged(final MouseEvent e, final ZirkelCanvas zc) {
if (!Dragging)
return;
final double x = zc.x(e.getX()), y = zc.y(e.getY());
D.addXY(x, y);
zc.repaint();
}
@Override
public void mouseReleased(final MouseEvent e, final ZirkelCanvas zc) {
Dragging = false;
zc.repaint();
}
@Override
public void showStatus(final ZirkelCanvas zc) {
zc.showStatus(Global.name("message.draw"));
}
@Override
public void reset(final ZirkelCanvas zc) {
zc.clearSelected();
}
@Override
public boolean useSmartBoard() {
return false;
}
}

View file

@ -0,0 +1,113 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
// file: Hider.java
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.util.Vector;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.ConstructionObject;
public class EditTool extends ObjectConstructor {
boolean Other;
Vector V;
public void mousePressed(final MouseEvent e, ConstructionObject o,
final ZirkelCanvas zc) {
if (!e.isShiftDown()) zc.clearMultipleSelection();
zc.startSelectionRectangle(e.getX(), e.getY());
Other=(e.isShiftDown()&&o==null);
if (o==null) {
o=zc.selectObject(e.getX(), e.getY());
if (o==null) {
return;
}
}
setConstructionObject(o, zc);
}
@Override
public void setConstructionObject(ConstructionObject obj, ZirkelCanvas zc) {
if (obj.isKeep()) {
return;
}
if (Other) {
zc.addMultipleSelection(obj);
return;
}
if (V!=null) {
V.addElement(obj);
obj.setSelected(true);
zc.clearSelected();
eric.bar.JPropertiesBar.EditObject(obj, true, false);
} else {
final String oldname=obj.getName();
eric.bar.JPropertiesBar.EditObject(obj, true, false);
if (!oldname.equals(obj.getName())) {
zc.updateTexts(obj, oldname);
}
}
V=null;
Other=false;
zc.validate();
zc.repaint();
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean simple) {
zc.indicateObjects(e.getX(), e.getY(), true);
}
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
mousePressed(e, null, zc);
}
@Override
public void showStatus(final ZirkelCanvas zc) {
zc.showStatus(Global.name("message.edit"));
}
@Override
public void reset(final ZirkelCanvas zc) {
zc.clearSelected();
V=null;
Other=false;
}
@Override
public void mouseReleased(final MouseEvent e, final ZirkelCanvas zc) {
zc.validCurrentMultipleSelection();
}
@Override
public void mouseDragged(final MouseEvent e, final ZirkelCanvas zc) {
zc.actualiseSelectionRectangle(e.getX(), e.getY());
}
}

View file

@ -0,0 +1,65 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
// file: Hider.java
import java.awt.event.MouseEvent;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.ConstructionObject;
public class HiderTool extends ObjectConstructor {
boolean isShiftDown=false;
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
isShiftDown=e.isShiftDown();
final ConstructionObject o=zc.selectObject(e.getX(), e.getY());
setConstructionObject(o, zc);
}
@Override
public void setConstructionObject(ConstructionObject obj, ZirkelCanvas zc) {
if (obj==null) {
return;
}
if (isShiftDown) {
obj.setSuperHidden(true);
} else {
obj.setHidden(!obj.isHidden());
}
zc.repaint();
zc.reloadCD();
zc.update_distant(obj, 3);
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean simple) {
zc.indicateObjects(e.getX(), e.getY());
}
@Override
public void showStatus(final ZirkelCanvas zc) {
zc.showStatus(Global.name("message.hide", "Hide: Select an object!"));
}
}

View file

@ -0,0 +1,85 @@
/*
Copyright 2006 Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
import rene.zirkel.objects.*;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.construction.Selector;
import rene.zirkel.graphics.TrackPainter;
import rene.zirkel.tools.ObjectTracker;
/**
*
* @author erichake
*/
public class JLocusObjectTracker extends ObjectTracker implements TrackPainter,
Runnable, Selector {
public JLocusObjectTracker() {
// System.out.println("JLocusObjectTracker");
}
public JLocusObjectTracker(final ConstructionObject p,
final PointObject pm, final ConstructionObject o,
final ZirkelCanvas zc, final boolean animate, final boolean paint,
final ConstructionObject po[]) {
super(p, pm, o, zc, animate, paint, po);
}
/**
* it simply create the locus object, without any animation
*/
@Override
public void run() {
animate(ZC);
}
/**
* No animation : it simply create the locus object
*
* @param zc
*/
@Override
public void animate(final ZirkelCanvas zc) {
// The DontPaint switch will be reset off at the end
zc.setDontPaint(true);
TrackObject t =null;
if (P instanceof PointObject) {
// Il s'agit d'un lieu de point (on utilise le nouvel objet)
t = new JLocusTrackObject(zc.getConstruction(), P,
PO, PN, O, PM);
}else{
// Il s'agit d'une enveloppe de droite (on utilise l'ancien objet)
t = new TrackObject(zc.getConstruction(), P,
PO, PN, O, PM);
}
// OldTrackObject t=new OldTrackObject(zc.getConstruction(),
// P,PO,PN,O,PM);
t.setDefaults();
zc.addObject(t);
reset(zc);
zc.validate();
zc.setDontPaint(false);
}
}

View file

@ -0,0 +1,175 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
// file: Binder.java
import eric.JSelectPopup;
import eric.JSprogram.ScriptThread;
import java.awt.event.MouseEvent;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.construction.Selector;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.AreaObject;
import rene.zirkel.objects.ConstructionObject;
import rene.zirkel.objects.PointObject;
import rene.zirkel.objects.ExpressionObject;
import rene.zirkel.objects.FunctionObject;
import rene.zirkel.objects.PointonObject;
import rene.zirkel.objects.PrimitiveCircleObject;
import rene.zirkel.objects.PrimitiveLineObject;
import rene.zirkel.objects.SegmentObject;
public class JSmacroTool extends ObjectConstructor implements Selector {
ObjectConstructor OC;
String MSG;
String TYPE;
ScriptThread TH;
ConstructionObject O=null;
boolean Point = false;
public JSmacroTool(ZirkelCanvas zc, ScriptThread th, String msg, String type, ObjectConstructor oc) {
OC=oc;
MSG=msg;
TYPE=type;
TH=th;
zc.repaint();
}
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
if (TYPE.equals("Point")) {
Point = true;
O=zc.selectCreatePoint(e.getX(), e.getY(), e.isAltDown());
//TH.setJSO(O);
} else if (TYPE.equals("Segment")) {
O=zc.selectSegment(e.getX(), e.getY());
//TH.setJSO(O);
} else if (TYPE.equals("Line")) {
O=zc.selectLine(e.getX(), e.getY());
//TH.setJSO(O);
} else if (TYPE.equals("Circle")) {
O=zc.selectCircle(e.getX(), e.getY());
//TH.setJSO(O);
} else if (TYPE.equals("Expression")) {
O=zc.selectObject(e.getX(), e.getY());
//TH.setJSO(O);
} else if (TYPE.equals("Polygon")) {
O=zc.selectObject(e.getX(), e.getY());
//TH.setJSO(O);
} else if(TYPE.equals("Function")){
O=zc.selectObject(e.getX(), e.getY(), true);
}
setConstructionObject(O, zc);
// if (TH.getJSO()!=null) {
// O.setSelected(true);
// }
}
@Override
public void setConstructionObject(ConstructionObject O, ZirkelCanvas zc){
if ((JSelectPopup.isCallerObject())&&(O instanceof PointonObject)&&Point) {
int x=JSelectPopup.getMouseX();
int y=JSelectPopup.getMouseY();
PointObject o=new PointObject(zc.getConstruction(), zc.x(x), zc.y(y), O);
o.setUseAlpha(true);
zc.addObject(o);
zc.validate();
o.setDefaults();
zc.repaint();
o.edit(zc, false, false);
O=o;
}
TH.setJSO(O);
if (TH.getJSO()!=null) {
O.setSelected(true);
}
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean simple) {
if (TYPE.equals("Point")) {
zc.indicateCreatePoint(e.getX(), e.getY(), true);
} else {
zc.indicateWithSelector(e.getX(), e.getY(), this);
}
}
@Override
public boolean isAdmissible(final ZirkelCanvas zc,
final ConstructionObject o) {
if ((o instanceof PointObject)&&(TYPE.equals("Point"))) {
return true;
} else if ((o instanceof PrimitiveLineObject)&&(TYPE.equals("Line"))) {
return true;
} else if ((o instanceof PrimitiveCircleObject)&&(TYPE.equals("Circle"))) {
return true;
} else if ((o instanceof SegmentObject)&&(TYPE.equals("Segment"))) {
return true;
} else if ((o instanceof ExpressionObject)&&(TYPE.equals("Expression"))) {
return true;
} else if ((o instanceof AreaObject)&&(TYPE.equals("Polygon"))) {
return true;
} else if ((o instanceof FunctionObject)&&(TYPE.equals("Function"))) {
return true;
} else {
return false;
}
}
@Override
public void showStatus(final ZirkelCanvas zc) {
zc.showStatus(MSG);
}
@Override
public void reset(final ZirkelCanvas zc) {
super.reset(zc);
zc.setTool(OC);
zc.validate();
zc.repaint();
}
@Override
public synchronized void invalidate(final ZirkelCanvas zc) {
if (O==null) {
// TH.invalidII();
TH.killme();
}
}
public void invalidate_and_saveoc(final ZirkelCanvas zc, final ObjectConstructor oc){
OC = oc;
invalidate(zc);
}
@Override
public boolean useSmartBoard() {
return false;
}
public ObjectConstructor getPreviousTool(){
return OC;
}
}

View file

@ -0,0 +1,117 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
// file: MoveConstructor.java
import java.awt.event.MouseEvent;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.ConstructionObject;
public class LabelMover extends ObjectConstructor {
ConstructionObject P;
ObjectConstructor OC;
int X, Y;
double OX, OY;
public LabelMover(final ObjectConstructor oc, final ZirkelCanvas zc,
final int x, final int y, final ConstructionObject p,
final boolean shift) {
OC = oc;
P = p;
if (shift || !P.canKeepClose()) {
X = x;
Y = y;
P.setKeepClose(false);
OX = P.xcOffset();
OY = P.ycOffset();
} else {
P.setKeepClose(zc.x(x), zc.y(y));
}
if (P != null) {
P.setLabelSelected(true);
zc.repaint();
showStatus(zc);
}
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean simple) {
}
@Override
public void mouseDragged(final MouseEvent e, final ZirkelCanvas zc) {
if (P == null)
return;
if (P.isKeepClose()) {
P.setKeepClose(zc.x(e.getX()), zc.y(e.getY()));
} else {
P.setcOffset(OX + zc.dx(e.getX() - X), OY + zc.dy(Y - e.getY()));
}
zc.validate();
zc.repaint();
}
@Override
public void mouseReleased(final MouseEvent e, final ZirkelCanvas zc) {
if (P == null)
return;
P.setLabelSelected(false);
zc.repaint();
P = null;
showStatus(zc);
zc.setTool(OC);
}
@Override
public void reset(final ZirkelCanvas zc) {
zc.clearSelected();
P.setLabelSelected(false);
zc.repaint();
}
public void resetPoint() {
if (P != null) {
P.setKeepClose(false);
P.setcOffset(0, 0);
}
}
@Override
public void showStatus(final ZirkelCanvas zc) {
if (P == null)
zc.showStatus(Global.name("message.label.select",
"Move Label: Select a label"));
else
zc.showStatus(Global.name("message.label.move",
"Move Label: Move the label"));
}
@Override
public boolean useSmartBoard() {
return false;
}
}

View file

@ -0,0 +1,106 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
// file: Binder.java
import eric.bar.JPropertiesBar;
import java.awt.event.MouseEvent;
import java.util.Enumeration;
import javax.swing.SwingUtilities;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.construction.Selector;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.ConstructionObject;
import rene.zirkel.objects.PointObject;
import rene.zirkel.structures.MagnetObj;
public class MagnetTool extends ObjectConstructor implements Selector {
ObjectConstructor OC;
PointObject P;
public MagnetTool(final ZirkelCanvas zc, final PointObject p,
final ObjectConstructor oc) {
P=p;
OC=oc;
}
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
final ConstructionObject o=zc.selectWithSelector(e.getX(), e.getY(),this);
setConstructionObject(o, zc);
}
@Override
public void setConstructionObject(ConstructionObject o, ZirkelCanvas zc) {
if (o==null) {
reset(zc);
return;
}
if (o==P) {
return;
}
if (o.selected()) {
P.removeMagnetObject(o.getName());
o.setSelected(false);
JPropertiesBar.RefreshBar();
} else {
P.addMagnetObject(o.getName());
P.selectMagnetObjects(true);
JPropertiesBar.RefreshBar();
}
zc.repaint();
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean simple) {
zc.indicateWithSelector(e.getX(), e.getY(), this);
}
public boolean isAdmissible(final ZirkelCanvas zc,
final ConstructionObject o) {
return true;
// if ((o instanceof InsideObject || o instanceof PointonObject) &&
// !zc.getConstruction().dependsOn(o,P)) return true;
// return false;
}
@Override
public void showStatus(final ZirkelCanvas zc) {
zc.showStatus(Global.Loc("props.magnetmessage"));
}
@Override
public void reset(final ZirkelCanvas zc) {
super.reset(zc);
zc.setTool(OC);
zc.validate();
JPropertiesBar.RefreshBar();
zc.repaint();
}
@Override
public boolean useSmartBoard() {
return false;
}
}

View file

@ -0,0 +1,112 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
// file: MetaMover.java
import java.util.ArrayList;
import java.util.Enumeration;
import eric.GUI.palette.PaletteManager;
import eric.bar.JPropertiesBar;
import java.awt.Cursor;
import java.awt.event.MouseEvent;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.AreaObject;
import rene.zirkel.objects.ConstructionObject;
import rene.zirkel.objects.FixedAngleObject;
import rene.zirkel.objects.FixedCircleObject;
import rene.zirkel.objects.MoveableObject;
import rene.zirkel.objects.PointObject;
public class MetaMover extends MoverTool {
ObjectConstructor OC;
ConstructionObject PP;
public MetaMover(final ObjectConstructor oc, final ZirkelCanvas zc,
final ConstructionObject p, final MouseEvent e) {
OC=oc;
PP=P=p;
oc.pause(true);
if (P!=null) {
P.setSelected(true);
ShowsValue=P.showValue();
ShowsName=P.showName();
zc.repaint();
showStatus(zc);
zc.setCursor(new Cursor(Cursor.MOVE_CURSOR));
if (P instanceof MoveableObject) {
((MoveableObject) P).startDrag(zc.x(e.getX()), zc.y(e.getY()));
}
if (ZCG!=null) {
ZCG.dispose();
ZCG=null;
}
ZCG=zc.getGraphics();
if ((P instanceof PointObject)&&(P instanceof MoveableObject)) {
zc.prepareDragActionScripts(P);
}
}
}
@Override
public void mouseReleased(final MouseEvent e, final ZirkelCanvas zc) {
if (P==null) {
return;
}
if (ZCG!=null) {
ZCG.dispose();
ZCG=null;
}
zc.getConstruction().haveChanged();
JPropertiesBar.RefreshBar();
zc.setCursor(Cursor.getDefaultCursor());
P.setSelected(false);
P.setShowValue(ShowsValue);
P.setShowName(ShowsName);
zc.validate();
if (Grab) {
zc.grab(false);
Grab=false;
}
if (ChangedDrawable) {
if (P instanceof FixedCircleObject) {
((FixedCircleObject) P).setDragable(WasDrawable);
} else if (P instanceof FixedAngleObject) {
((FixedAngleObject) P).setDragable(WasDrawable);
}
}
zc.stopDragAction();
zc.clearSelected();
zc.repaint();
P=null;
V=null;
Selected=false;
zc.setTool(OC);
OC.pause(false);
zc.validate();
zc.repaint();
}
}

View file

@ -0,0 +1,550 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
import eric.GUI.palette.PaletteManager;
import eric.bar.JProperties;
import eric.bar.JPropertiesBar;
import java.awt.Cursor;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Enumeration;
import rene.gui.Global;
import rene.util.MyVector;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.AreaObject;
import rene.zirkel.objects.ConstructionObject;
import rene.zirkel.objects.FixedAngleObject;
import rene.zirkel.objects.FixedCircleObject;
import rene.zirkel.objects.MoveableObject;
import rene.zirkel.objects.PointObject;
import rene.zirkel.objects.QuadricObject;
import rene.zirkel.objects.SegmentObject;
import rene.zirkel.objects.TwoPointLineObject;
import rene.zirkel.objects.VectorObject;
/**
* @author Rene
* Tool to move objects around. Can move several objects at once.
*/
// with addons by Dibs for 3D
public class MoverTool extends ObjectConstructor {
ConstructionObject P;
boolean Selected=false;
boolean ShowsValue, ShowsName;
boolean Grab;
boolean WasDrawable, ChangedDrawable;
MyVector V=null;
double OldX, OldY;
double OldX3D, OldY3D, OldZ3D;
Graphics ZCG;
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
if (!Selected&&V!=null) {
zc.clearSelected();
}
if (e.isControlDown()&&V==null) // force a fixed angle or fixed circle to become drawable!
{
P=zc.selectObject(e.getX(), e.getY());
ChangedDrawable=false;
if (P instanceof FixedCircleObject
&&((FixedCircleObject) P).fixedByNumber()) {
WasDrawable=((FixedCircleObject) P).isDragable();
ChangedDrawable=true;
((FixedCircleObject) P).setDragable(true);
} else if (P instanceof FixedAngleObject
&&((FixedAngleObject) P).fixedByNumber()) {
WasDrawable=((FixedAngleObject) P).isDragable();
ChangedDrawable=true;
((FixedAngleObject) P).setDragable(true);
} else {
P=null;
}
}
if (P==null) // no forced moveable fixed circle or angle
{
if (V!=null) // try to select another point
{
P=zc.selectMoveablePoint(e.getX(), e.getY());
} else // try to select any moveable object
{
P=zc.selectMoveableObject(e.getX(), e.getY());
}
}
if (P!=null&&V!=null) // Check, if we have that point already:
{
final Enumeration en=V.elements();
while (en.hasMoreElements()) {
if (P==en.nextElement()) // point found
{
if (e.isShiftDown()) {
P=null;
} // selected a point twice, but want still more points
else {
V.removeElement(P);
}
// remove the point from the list and start dragging
break;
}
}
}
if (P!=null) // point is selected for movement
{
P.setSelected(true);
zc.setCursor(new Cursor(Cursor.MOVE_CURSOR));
} else // point was chosen from a list of objects
{
Selected=(zc.findSelectedObject()!=null);
}
// Highlight all selected points:
if (V!=null) {
final Enumeration en=V.elements();
while (en.hasMoreElements()) {
((PointObject) en.nextElement()).setSelected(true);
}
}
if (P!=null) {
if (P instanceof PointObject) {
if (e.isShiftDown()) // want more points!
{
if (V==null) {
V=new MyVector();
}
if (P!=null) {
V.addElement(P);
}
P=null;
} else if (e.isControlDown()) // show current construction while moving
{
zc.grab(true);
Grab=true;
} else // remember old point position
{
OldX=((PointObject) P).getX();
OldY=((PointObject) P).getY();
if (P instanceof PointObject&&((PointObject)P).is3D()) {
OldX3D=((PointObject) P).getX3D();
OldY3D=((PointObject) P).getY3D();
OldZ3D=((PointObject) P).getZ3D();
}
if(((PointObject) P) instanceof MoveableObject){
zc.prepareDragActionScripts(P);
}
}
} else if (P instanceof MoveableObject) // call startDrag method of the object
{
((MoveableObject) P).startDrag(zc.x(e.getX()), zc.y(e.getY()));
// System.out.println("start dragging "+P.getName());
V=null;
}
if (ZCG!=null) {
ZCG.dispose();
ZCG=null;
}
ZCG=zc.getGraphics();
}
zc.repaint();
showStatus(zc);
if (P!=null) {
ShowsName=P.showName();
ShowsValue=P.showValue();
}
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean simple) {
zc.indicateMoveableObjects(e.getX(), e.getY(), e.isControlDown());
}
boolean IntersectionBecameInvalid=false;
@Override
public void setConstructionObject(ConstructionObject obj, ZirkelCanvas zc) {
P=obj;
if (P!=null) {
if (V==null) {
V=new MyVector();
}
V.addElement(P);
}
}
/**
* Drag a point in a new location and recompute the construction. Can show
* the name and the value of the object to be dragged. Take care not to move
* the point while ZirkelCanvas.paint is active. ZirkelCanvas.paint is
* synchronized!
*
* @see rene.zirkel.ObjectConstructor#mouseDragged(java.awt.event.MouseEvent,
* rene.zirkel.ZirkelCanvas)
*/
@Override
public void mouseDragged(final MouseEvent e, final ZirkelCanvas zc) {
if (P==null) {
return;
}
if (P==zc.getConstruction().find("X")||P==zc.getConstruction().find("Y")||P==zc.getConstruction().find("Z")) {
return;
}
// System.out.println("dragging "+P.getName());
zc.getConstruction().dontAlternate(false);
synchronized (zc) {
double oldx=0, oldy=0;
double oldx3D=0, oldy3D=0, oldz3D=0;
if ((Global.getParameter("restrictedmove", false)||e.isShiftDown())
&&P instanceof PointObject) {
if (IntersectionBecameInvalid) {
zc.getConstruction().dontAlternate(true);
IntersectionBecameInvalid=false;
}
}
try {
oldx=((PointObject) P).getX();
oldy=((PointObject) P).getY();
oldx3D=((PointObject) P).getX3D();
oldy3D=((PointObject) P).getY3D();
oldz3D=((PointObject) P).getZ3D();
} catch (final Exception ex) {}
((MoveableObject) P).dragTo(zc.x(e.getX()), zc.y(e.getY()));
if ((Global.getParameter("options.movename", false)&&!P.isFixed())
||(Global.getParameter("options.movefixname", true)&&P.isFixed())) {
P.setShowValue(true);
P.setShowName(true);
}
if (zc.is3D()&&P instanceof PointObject&&((PointObject) P).getBound()!=null) { // Dibs : 2D -> 3D
//zc.validate(); Dibs
if (((PointObject) P).getBound() instanceof AreaObject) {
AreaObject surface= (AreaObject) ((PointObject) P).getBound();
if (((AreaObject)surface).V.size()>2&&((PointObject) surface.V.get(0)).is3D()&&((PointObject) surface.V.get(1)).is3D()&&((PointObject) surface.V.get(2)).is3D()) {
try {
double x0=((PointObject) surface.V.get(0)).getX3D();
double y0=((PointObject) surface.V.get(0)).getY3D();
double z0=((PointObject) surface.V.get(0)).getZ3D();
double x1=((PointObject) surface.V.get(1)).getX3D();
double y1=((PointObject) surface.V.get(1)).getY3D();
double z1=((PointObject) surface.V.get(1)).getZ3D();
double x2=((PointObject) surface.V.get(2)).getX3D();
double y2=((PointObject) surface.V.get(2)).getY3D();
double z2=((PointObject) surface.V.get(2)).getZ3D();
double x_O=zc.getConstruction().find("O").getX();
double x_X=zc.getConstruction().find("X").getX();
double x_Y=zc.getConstruction().find("Y").getX();
double x_Z=zc.getConstruction().find("Z").getX();
double y_O=zc.getConstruction().find("O").getY();
double y_X=zc.getConstruction().find("X").getY();
double y_Y=zc.getConstruction().find("Y").getY();
double y_Z=zc.getConstruction().find("Z").getY();
double coeffa=(x1-x0)*(x_X-x_O)+(y1-y0)*(x_Y-x_O)+(z1-z0)*(x_Z-x_O);
double coeffb=(x2-x0)*(x_X-x_O)+(y2-y0)*(x_Y-x_O)+(z2-z0)*(x_Z-x_O);
double coeffc=(x1-x0)*(y_X-y_O)+(y1-y0)*(y_Y-y_O)+(z1-z0)*(y_Z-y_O);
double coeffd=(x2-x0)*(y_X-y_O)+(y2-y0)*(y_Y-y_O)+(z2-z0)*(y_Z-y_O);
double coeffe=P.getX()-x_O-x0*(x_X-x_O)-y0*(x_Y-x_O)-z0*(x_Z-x_O);
double coefff=P.getY()-y_O-x0*(y_X-y_O)-y0*(y_Y-y_O)-z0*(y_Z-y_O);
double alpha1=(coeffe*coeffd-coefff*coeffb)/(coeffa*coeffd-coeffb*coeffc);
double beta1=(coeffa*coefff-coeffc*coeffe)/(coeffa*coeffd-coeffb*coeffc);
final double xM=x0+alpha1*(x1-x0)+beta1*(x2-x0);
final double yM=y0+alpha1*(y1-y0)+beta1*(y2-y0);
final double zM=z0+alpha1*(z1-z0)+beta1*(z2-z0);
((PointObject) P).setX3D(xM);
((PointObject) P).setY3D(yM);
((PointObject) P).setZ3D(zM);
((PointObject) P).setFixed("x(O)+("+xM+")*(x(X)-x(O))+("+yM+")*(x(Y)-x(O))+("+z1+zM+")*(x(Z)-x(O))", "y(O)+("+xM+")*(y(X)-y(O))+("+yM+")*(y(Y)-y(O))+("+zM+")*(y(Z)-y(O))");
((PointObject) P).setIs3D(true);
P.validate();
} catch (final Exception eBary) {
}
}
}
else if (((PointObject) P).getBound() instanceof TwoPointLineObject) {
TwoPointLineObject ligne= (TwoPointLineObject) ((PointObject) P).getBound();
if (((PointObject) ligne.getP1()).is3D()&&((PointObject) ligne.getP2()).is3D()) {
try {
double x1=((PointObject) ligne.getP1()).getX3D();
double y1=((PointObject) ligne.getP1()).getY3D();
double z1=((PointObject) ligne.getP1()).getZ3D();
double x2=((PointObject) ligne.getP2()).getX3D();
double y2=((PointObject) ligne.getP2()).getY3D();
double z2=((PointObject) ligne.getP2 ()).getZ3D();
double x_O=zc.getConstruction().find("O").getX();
double x_X=zc.getConstruction().find("X").getX();
double x_Y=zc.getConstruction().find("Y").getX();
double x_Z=zc.getConstruction().find("Z").getX();
double alpha1=(P.getX()-x_O-x1*(x_X-x_O)-y1*(x_Y-x_O)-z1*(x_Z-x_O))/((x2-x1)*(x_X-x_O)+(y2-y1)*(x_Y-x_O)+(z2-z1)*(x_Z-x_O));
if (x1==x2&&y1==y2) {
double y_O=zc.getConstruction().find("O").getY();
double y_X=zc.getConstruction().find("X").getY();
double y_Y=zc.getConstruction().find("Y").getY();
double y_Z=zc.getConstruction().find("Z").getY();
alpha1=(P.getY()-y_O-x1*(y_X-y_O)-y1*(y_Y-y_O)-z1*(y_Z-y_O))/((x2-x1)*(y_X-y_O)+(y2-y1)*(y_Y-y_O)+(z2-z1)*(y_Z-y_O));
}
final double xM=x1+alpha1*(x2-x1);
final double yM=y1+alpha1*(y2-y1);
final double zM=z1+alpha1*(z2-z1);
((PointObject) P).setX3D(xM);
((PointObject) P).setY3D(yM);
((PointObject) P).setZ3D(zM);
((PointObject) P).setIs3D(true);
((PointObject) P).setFixed("x(O)+("+xM+")*(x(X)-x(O))+("+yM+")*(x(Y)-x(O))+("+z1+zM+")*(x(Z)-x(O))", "y(O)+("+xM+")*(y(X)-y(O))+("+yM+")*(y(Y)-y(O))+("+zM+")*(y(Z)-y(O))");
} catch (final Exception eBary) {
}
}
}
else if (((PointObject) P).getBound() instanceof QuadricObject) {
QuadricObject quadrique= (QuadricObject) ((PointObject) P).getBound();
if (quadrique.getP()[0].is3D()&&quadrique.getP()[1].is3D()&&quadrique.getP()[2].is3D()&&quadrique.getP()[3].is3D()&&quadrique.getP()[4].is3D()) {
try {
double x0=quadrique.getP()[0].getX3D();
double y0=quadrique.getP()[0].getY3D();
double z0=quadrique.getP()[0].getZ3D();
double x1=quadrique.getP()[1].getX3D();
double y1=quadrique.getP()[1].getY3D();
double z1=quadrique.getP()[1].getZ3D();
double x2=quadrique.getP()[2].getX3D();
double y2=quadrique.getP()[2].getY3D();
double z2=quadrique.getP()[2].getZ3D();
double x_O=zc.getConstruction().find("O").getX();
double x_X=zc.getConstruction().find("X").getX();
double x_Y=zc.getConstruction().find("Y").getX();
double x_Z=zc.getConstruction().find("Z").getX();
double y_O=zc.getConstruction().find("O").getY();
double y_X=zc.getConstruction().find("X").getY();
double y_Y=zc.getConstruction().find("Y").getY();
double y_Z=zc.getConstruction().find("Z").getY();
double coeffa=(x1-x0)*(x_X-x_O)+(y1-y0)*(x_Y-x_O)+(z1-z0)*(x_Z-x_O);
double coeffb=(x2-x0)*(x_X-x_O)+(y2-y0)*(x_Y-x_O)+(z2-z0)*(x_Z-x_O);
double coeffc=(x1-x0)*(y_X-y_O)+(y1-y0)*(y_Y-y_O)+(z1-z0)*(y_Z-y_O);
double coeffd=(x2-x0)*(y_X-y_O)+(y2-y0)*(y_Y-y_O)+(z2-z0)*(y_Z-y_O);
double coeffe=P.getX()-x_O-x0*(x_X-x_O)-y0*(x_Y-x_O)-z0*(x_Z-x_O);
double coefff=P.getY()-y_O-x0*(y_X-y_O)-y0*(y_Y-y_O)-z0*(y_Z-y_O);
double alpha1=(coeffe*coeffd-coefff*coeffb)/(coeffa*coeffd-coeffb*coeffc);
double beta1=(coeffa*coefff-coeffc*coeffe)/(coeffa*coeffd-coeffb*coeffc);
((PointObject) P).setX3D(x0+alpha1*(x1-x0)+beta1*(x2-x0));
((PointObject) P).setY3D(y0+alpha1*(y1-y0)+beta1*(y2-y0));
((PointObject) P).setZ3D(z0+alpha1*(z1-z0)+beta1*(z2-z0));
((PointObject) P).setIs3D(true);
} catch (final Exception eBary) {
}
}
}
}
else if (P instanceof PointObject&&((PointObject) P).is3D()&&!((PointObject) P).fixed3D()&&P!=zc.getConstruction().find("O")) {
try {
double Dx3D = Math.sin(Math.toRadians(zc.getConstruction().find("E10").getValue()))*(P.getX()-oldx)-Math.sin(Math.toRadians(zc.getConstruction().find("E11").getValue()))*Math.cos(Math.toRadians(zc.getConstruction().find("E10").getValue()))*(P.getY()-oldy);
double Dy3D = Math.cos(Math.toRadians(zc.getConstruction().find("E10").getValue()))*(P.getX()-oldx)+Math.sin(Math.toRadians(zc.getConstruction().find("E11").getValue()))*Math.sin(Math.toRadians(zc.getConstruction().find("E10").getValue()))*(P.getY()-oldy);
double Dz3D = Math.cos(Math.toRadians(zc.getConstruction().find("E11").getValue()))*(P.getY()-oldy);
((PointObject) P).setX3D(oldx3D+Dx3D);
((PointObject) P).setY3D(oldy3D+Dy3D);
((PointObject) P).setZ3D(oldz3D+Dz3D);
((PointObject) P).setFixed("x(O)+("+(oldx3D+Dx3D)+")*(x(X)-x(O))+("+(oldy3D+Dy3D)+")*(x(Y)-x(O))+("+(oldz3D+Dz3D)+")*(x(Z)-x(O))", "y(O)+("+(oldx3D+Dx3D)+")*(y(X)-y(O))+("+(oldy3D+Dy3D)+")*(y(Y)-y(O))+("+(oldz3D+Dz3D)+")*(y(Z)-y(O))");
P.validate();
}
catch (final Exception f) {}
}
P.updateText();
if (V!=null&&P instanceof PointObject) {
if (!((PointObject)P).is3D()) {
final double dx=((PointObject) P).getX()-OldX, dy=((PointObject) P).getY()-OldY;
final Enumeration en=V.elements();
while (en.hasMoreElements()) {
PointObject p=(PointObject) en.nextElement();
p.move(p.getX()+dx, p.getY()+dy);
p.updateText();
}
OldX=((PointObject) P).getX();
OldY=((PointObject) P).getY();
}
else {
final double dx3D=((PointObject) P).getX3D()-OldX3D;
final double dy3D=((PointObject) P).getY3D()-OldY3D;
final double dz3D=((PointObject) P).getZ3D()-OldZ3D;
final Enumeration en3D=V.elements();
while (en3D.hasMoreElements()) {
PointObject p3D=(PointObject) en3D.nextElement();
if (p3D.is3D()) {
p3D.move3D(p3D.getX3D()+dx3D, p3D.getY3D()+dy3D,p3D.getZ3D()+dz3D);
p3D.updateText();
}
}
OldX3D=((PointObject) P).getX3D();
OldY3D=((PointObject) P).getY3D();
OldZ3D=((PointObject) P).getZ3D();
}
}
if (P instanceof PointObject) {
final PointObject Po=(PointObject) P;
if (Po.dependsOnItselfOnly()) {
Po.dontUpdate(true);
zc.dovalidate();
Po.dontUpdate(false);
}
Po.magnet();
// System.out.println("start dragging "+P.getName());
zc.runDragAction();
}
zc.validate();
if ((Global.getParameter("restrictedmove", false)||e.isShiftDown())
&&P instanceof PointObject
&&zc.getConstruction().intersectionBecameInvalid()) {
((PointObject) P).dragTo(oldx, oldy);
IntersectionBecameInvalid=true;
zc.validate();
}
if(JPropertiesBar.isBarVisible()){
JProperties.refreshCoords();
}
zc.update_distant(P, 2);
}
if (ZCG==null) {
ZCG=zc.getGraphics();
}
zc.paint(ZCG);
}
/**
* Release the mouse after dragging.
*
* @param e
* @param zc
* @param rightmouse
* Call comes from a right mouse drag!
*/
public void mouseReleased(final MouseEvent e, final ZirkelCanvas zc,
final boolean rightmouse) {
// System.out.println("released !");
// P.setShowValue(ShowsValue);
// P.setShowName(ShowsName);
if (P==null) {
return;
}
if (ZCG!=null) {
ZCG.dispose();
ZCG=null;
}
zc.getConstruction().haveChanged();
P.setShowValue(ShowsValue);
P.setShowName(ShowsName);
JPropertiesBar.RefreshBar();
zc.setCursor(Cursor.getDefaultCursor());
P.setSelected(false);
if (zc.getAxis_show()&&!rightmouse
&&Global.getParameter("grid.leftsnap", false)) {
P.snap(zc);
P.round();
P.updateText();
}
zc.validate();
if (Grab) {
zc.grab(false);
Grab=false;
}
if (ChangedDrawable) {
if (P instanceof FixedCircleObject) {
((FixedCircleObject) P).setDragable(WasDrawable);
} else if (P instanceof FixedAngleObject) {
((FixedAngleObject) P).setDragable(WasDrawable);
}
}
zc.stopDragAction();
zc.runUpAction(P);
zc.clearSelected();
zc.repaint();
P=null;
V=null;
Selected=false;
showStatus(zc);
}
@Override
public void mouseReleased(final MouseEvent e, final ZirkelCanvas zc) {
// if (P==null) {
// zc.clearSelectionRectangle();
// zc.repaint();
// zc.editMultipleSelection();
// }
mouseReleased(e, zc, false);
}
@Override
public void reset(final ZirkelCanvas zc) {
V=null;
P=null;
zc.clearSelected();
zc.repaint();
Selected=false;
}
@Override
public void resetFirstTime(final ZirkelCanvas zc) {
if (V!=null) {
V.removeAllElements();
}
zc.clearSelected();
zc.selectAllMoveableVisibleObjects();
final Graphics g=zc.getGraphics();
if (g!=null) {
zc.paint(g);
g.dispose();
try {
Thread.sleep(200);
} catch (final Exception e) {
}
zc.clearSelected();
}
zc.repaint();
Selected=false;
P=null;
V=null;
}
@Override
public void showStatus(final ZirkelCanvas zc) {
if (P==null&&!Selected) {
zc.showStatus(Global.name("message.move.select",
"Move: Select a point"));
} else if (Selected) {
zc.showStatus(Global.name("message.move.move",
"Move: Move the point"));
} else {
zc.showStatus(Global.name("message.move.move",
"Move: Move the point")
+" ("+P.getName()+")");
}
}
@Override
public boolean useSmartBoard() {
return false;
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,70 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
// file: Hider.java
import java.awt.event.MouseEvent;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.ConstructionObject;
public class RenamerTool extends ObjectConstructor {
boolean Enforce = false, Started = false;
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
final ConstructionObject o = zc.selectObject(e.getX(), e.getY());
if (o == null)
return;
if (o.isKeep())
return;
if (e.isShiftDown()) {
zc.renameABC(o, true, !Started);
Started = true;
} else
zc.renameABC(o, false, false);
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean simple) {
zc.indicateObjects(e.getX(), e.getY(), true);
}
@Override
public void showStatus(final ZirkelCanvas zc) {
zc.showStatus(Global.name("message.rename"));
}
@Override
public boolean useSmartBoard() {
return false;
}
@Override
public void reset(final ZirkelCanvas zc) {
Started = false;
}
}

View file

@ -0,0 +1,135 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
// file: Hider.java
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.TextField;
import java.awt.event.MouseEvent;
import eric.JEricPanel;
import rene.gui.ButtonAction;
import rene.gui.CloseDialog;
import rene.gui.MyLabel;
import rene.gui.MyPanel;
import rene.gui.Panel3D;
import rene.gui.TextFieldAction;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.ConstructionObject;
class ReorderDialog extends CloseDialog {
/**
*
*/
private static final long serialVersionUID = 1L;
String Name = "";
boolean Abort = true;
TextField Input;
public ReorderDialog(final ZirkelCanvas zc, final ConstructionObject o) {
super(zc.getFrame(), Global.name("reorder.title"), true);
setLayout(new BorderLayout());
final JEricPanel north = new MyPanel();
north.setLayout(new GridLayout(1, 0));
north.add(new MyLabel(o.getName() + " : "
+ Global.name("reorder.message")));
final ConstructionObject ol = zc.getConstruction().lastDep(o);
String s = "";
if (ol != null)
s = ol.getName();
north.add(Input = new TextFieldAction(this, "Reorder", s));
add("North", new Panel3D(north));
final JEricPanel south = new MyPanel();
south.add(new ButtonAction(this, Global.name("ok"), "OK"));
south.add(new ButtonAction(this, Global.name("abort"), "Close"));
add("South", south);
pack();
center(zc.getFrame());
setVisible(true);
}
@Override
public void doAction(final String o) {
if (o.equals("OK")) {
Abort = false;
Name = Input.getText();
doclose();
} else
super.doAction(o);
}
public String getResult() {
return Name;
}
@Override
public boolean isAborted() {
return Abort;
}
}
public class ReorderTool extends ObjectConstructor {
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
zc.y(e.getY());
final ConstructionObject o = zc.selectObject(e.getX(), e.getY());
if (o == null)
return;
final ReorderDialog d = new ReorderDialog(zc, o);
if (!d.isAborted()) {
final String name = d.getResult();
if (!name.equals("")) {
final ConstructionObject u = zc.getConstruction().find(name);
if (u == null) {
zc.warning(Global.name("reorder.notfound"));
return;
}
if (!zc.getConstruction().reorder(o, u))
zc.warning(Global.name("reorder.warning"));
} else if (!zc.getConstruction().reorder(o, null))
zc.warning(Global.name("reorder.warning"));
}
zc.repaint();
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean simple) {
zc.indicateObjects(e.getX(), e.getY());
}
@Override
public void showStatus(final ZirkelCanvas zc) {
zc.showStatus(Global.name("message.reorder",
"Reorder: Select an object!"));
}
@Override
public boolean useSmartBoard() {
return false;
}
}

View file

@ -0,0 +1,68 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
/*
* Created on 18.06.2004
*
*/
import java.awt.event.MouseEvent;
import java.util.Vector;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.ConstructionObject;
public class Ruler extends ObjectConstructor {
boolean Other;
Vector V;
public void mousePressed(final MouseEvent e, ConstructionObject o,
final ZirkelCanvas zc) {
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean simple) {
zc.indicateObjects(e.getX(), e.getY(), true);
}
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
mousePressed(e, null, zc);
}
@Override
public void showStatus(final ZirkelCanvas zc) {
zc.showStatus(Global.name("message.edit"));
}
@Override
public void reset(final ZirkelCanvas zc) {
zc.clearSelected();
V = null;
Other = false;
}
}

View file

@ -0,0 +1,77 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
// file: SetParameter.java
import java.awt.event.MouseEvent;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.ConstructionObject;
public class SaveJob extends ObjectConstructor {
public ConstructionObject Last;
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
zc.y(e.getY());
final ConstructionObject o = zc.selectObject(e.getX(), e.getY());
if (o == null)
return;
o.setSelected(true);
if (Last == null) {
Last = o;
showStatus(zc);
}
zc.repaint();
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean simple) {
zc.indicateObjects(e.getX(), e.getY());
}
@Override
public void reset(final ZirkelCanvas zc) {
super.reset(zc);
zc.clearSelected();
zc.getConstruction().clearTargets();
Last = null;
showStatus(zc);
}
@Override
public void showStatus(final ZirkelCanvas zc) {
if (Last == null)
zc.showStatus(Global.name("message.savejob.first"));
else
zc.showStatus(Global.name("message.savejob.second"));
}
@Override
public boolean useSmartBoard() {
return false;
}
}

View file

@ -0,0 +1,107 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
// file: SetParameter.java
import eric.JSprogram.ScriptItem;
import java.awt.event.MouseEvent;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.construction.Selector;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.ConstructionObject;
import rene.zirkel.objects.ExpressionObject;
import rene.zirkel.objects.PointObject;
public class Scripts_SetMouseDrag extends ObjectConstructor implements Selector {
ScriptItem ITEM;
public Scripts_SetMouseDrag(ScriptItem item) {
super();
ITEM=item;
}
public void addFromControl(ExpressionObject o,ZirkelCanvas zc){
if (o.selected()) {
o.setSelected(false);
ITEM.removeMouseDragTarget(o);
} else {
o.setSelected(true);
ITEM.addMouseDragTarget(o);
}
ITEM.refreshMouseDragInputField();
zc.repaint();
}
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
zc.y(e.getY());
final ConstructionObject o = zc.selectWithSelector(e.getX(), e.getY(),
this);
if (o==null) {
return;
}
if (o.selected()) {
o.setSelected(false);
ITEM.removeMouseDragTarget(o);
} else {
o.setSelected(true);
ITEM.addMouseDragTarget(o);
ITEM.removeMouseUpTarget(o);
}
ITEM.refreshMouseDragInputField();
zc.repaint();
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean simple) {
// zc.indicatePointObjects(e.getX(), e.getY());
zc.indicateWithSelector(e.getX(), e.getY(), this);
}
@Override
public void reset(final ZirkelCanvas zc) {
super.reset(zc);
zc.clearSelected();
showStatus(zc);
// zc.clearJob();
}
@Override
public void showStatus(final ZirkelCanvas zc) {
zc.showStatus(Global.Loc("JSmenu.dragaction.message"));
}
@Override
public boolean useSmartBoard() {
return false;
}
public boolean isAdmissible(final ZirkelCanvas zc,
final ConstructionObject o) {
if (o instanceof PointObject){
return true;
}
return false;
}
}

View file

@ -0,0 +1,84 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
// file: SetParameter.java
import eric.GUI.ZDialog.ZTextFieldAndLabel;
import eric.JSprogram.ScriptItem;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.ConstructionObject;
public class Scripts_SetMouseOver extends ObjectConstructor {
ScriptItem ITEM;
public Scripts_SetMouseOver(ScriptItem item) {
super();
ITEM=item;
}
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
zc.y(e.getY());
final ConstructionObject o=zc.selectPoint(e.getX(), e.getY());
if (o==null) {
return;
}
if (o.selected()) {
o.setSelected(false);
ITEM.removeMouseOverTarget(o);
} else {
o.setSelected(true);
ITEM.addMouseOverTarget(o);
}
ITEM.refreshMouseOverInputField();
zc.repaint();
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean simple) {
zc.indicatePointObjects(e.getX(), e.getY());
}
@Override
public void reset(final ZirkelCanvas zc) {
super.reset(zc);
zc.clearSelected();
showStatus(zc);
// zc.clearJob();
}
@Override
public void showStatus(final ZirkelCanvas zc) {
zc.showStatus(""); //otherwise, the ZTextFiledAndLabel are invisible on ZDialog windows when user ask them twice
// zc.showStatus(Global.name("message.savejob.second"));
}
@Override
public boolean useSmartBoard() {
return false;
}
}

View file

@ -0,0 +1,81 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
// file: SetParameter.java
import eric.JSprogram.ScriptItem;
import java.awt.event.MouseEvent;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.ConstructionObject;
public class Scripts_SetMouseUp extends ObjectConstructor {
ScriptItem ITEM;
public Scripts_SetMouseUp(ScriptItem item) {
super();
ITEM=item;
}
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
zc.y(e.getY());
final ConstructionObject o=zc.selectPoint(e.getX(), e.getY());
if (o==null) {
return;
}
if (o.selected()) {
o.setSelected(false);
ITEM.removeMouseUpTarget(o);
} else {
o.setSelected(true);
ITEM.addMouseUpTarget(o);
ITEM.removeMouseDragTarget(o);
}
ITEM.refreshMouseUpInputField();
zc.repaint();
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean simple) {
zc.indicatePointObjects(e.getX(), e.getY());
}
@Override
public void reset(final ZirkelCanvas zc) {
super.reset(zc);
zc.clearSelected();
showStatus(zc);
// zc.clearJob();
}
@Override
public void showStatus(final ZirkelCanvas zc) {
zc.showStatus(""); //otherwise, the ZTextFiledAndLabel are invisible on ZDialog windows when user ask them twice
// zc.showStatus(Global.name("message.savejob.second"));
}
@Override
public boolean useSmartBoard() {
return false;
}
}

View file

@ -0,0 +1,213 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
import java.awt.Cursor;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.constructors.ObjectConstructor;
public class SelectTool extends ObjectConstructor {
private static final int hotSize=5;
private Point DragLoc=null;
private Point GrowEast=null;
private Point GrowSouth=null;
private Point GrowNorth=null;
private Point GrowWest=null;
private Point GrowSouthEast=null;
private ZirkelCanvas ZC;
public SelectTool(ZirkelCanvas zc) {
ZC=zc;
zc.showCopyRectangle();
}
public boolean isInside(Point pt, ZirkelCanvas zc) {
Rectangle sel=(Rectangle) zc.getCopyRectangle();
if (sel==null) {
return false;
}
sel=(Rectangle) sel.clone();
sel.grow(-hotSize, -hotSize);
return sel.contains(pt);
}
public boolean isEast(Point pt, ZirkelCanvas zc) {
Rectangle sel=(Rectangle) zc.getCopyRectangle();
if (sel==null) {
return false;
}
boolean bool=(Math.abs(pt.x-sel.x-sel.width)<hotSize);
bool=bool&&(pt.y>sel.y)&&(pt.y<(sel.y+sel.height));
return bool;
}
public boolean isSouth(Point pt, ZirkelCanvas zc) {
Rectangle sel=(Rectangle) zc.getCopyRectangle();
if (sel==null) {
return false;
}
boolean bool=(Math.abs(pt.y-sel.y-sel.height)<hotSize);
bool=bool&&(pt.x>sel.x)&&(pt.x<(sel.x+sel.width));
return bool;
}
public boolean isNorth(Point pt, ZirkelCanvas zc) {
Rectangle sel=(Rectangle) zc.getCopyRectangle();
if (sel==null) {
return false;
}
boolean bool=(Math.abs(pt.y-sel.y)<hotSize);
bool=bool&&(pt.x>sel.x)&&(pt.x<(sel.x+sel.width));
return bool;
}
public boolean isWest(Point pt, ZirkelCanvas zc) {
Rectangle sel=(Rectangle) zc.getCopyRectangle();
if (sel==null) {
return false;
}
boolean bool=(Math.abs(pt.x-sel.x)<hotSize);
bool=bool&&(pt.y>sel.y)&&(pt.y<(sel.y+sel.height));
return bool;
}
public boolean isSouthEast(Point pt, ZirkelCanvas zc) {
Rectangle sel=(Rectangle) zc.getCopyRectangle();
if (sel==null) {
return false;
}
boolean bool=(Math.abs(pt.x-sel.x-sel.width)<hotSize);
bool=bool&&(Math.abs(pt.y-sel.y-sel.height)<hotSize);
return bool;
}
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
if (isInside(e.getPoint(), zc)) {
DragLoc=MouseInfo.getPointerInfo().getLocation();
} else if (isSouthEast(e.getPoint(), zc)) {
GrowSouthEast=MouseInfo.getPointerInfo().getLocation();
} else if (isEast(e.getPoint(), zc)) {
GrowEast=MouseInfo.getPointerInfo().getLocation();
} else if (isSouth(e.getPoint(), zc)) {
GrowSouth=MouseInfo.getPointerInfo().getLocation();
} else if (isNorth(e.getPoint(), zc)) {
GrowNorth=MouseInfo.getPointerInfo().getLocation();
} else if (isWest(e.getPoint(), zc)) {
GrowWest=MouseInfo.getPointerInfo().getLocation();
} else {
zc.startCopyRectangle(e.getX(), e.getY());
}
zc.keepCopyRectangleInside();
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean simple) {
if (isInside(e.getPoint(), zc)) {
zc.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
} else if (isSouthEast(e.getPoint(), zc)) {
zc.setCursor(Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR));
} else if (isEast(e.getPoint(), zc)) {
zc.setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));
} else if (isSouth(e.getPoint(), zc)) {
zc.setCursor(Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR));
} else if (isNorth(e.getPoint(), zc)) {
zc.setCursor(Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR));
} else if (isWest(e.getPoint(), zc)) {
zc.setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR));
} else {
zc.setCursor(Cursor.getDefaultCursor());
}
}
@Override
public void mouseDragged(final MouseEvent e, final ZirkelCanvas zc) {
Point pt=MouseInfo.getPointerInfo().getLocation();
if (DragLoc!=null) {
int dx=pt.x-DragLoc.x;
int dy=pt.y-DragLoc.y;
zc.translateCopyRectangle(dx, dy);
DragLoc=pt;
} else if (GrowSouthEast!=null) {
int dx=pt.x-GrowSouthEast.x;
int dy=pt.y-GrowSouthEast.y;
zc.growCopyRectangle(dx, dy);
GrowSouthEast=pt;
} else if (GrowEast!=null) {
int dx=pt.x-GrowEast.x;
zc.growCopyRectangle(dx, 0);
GrowEast=pt;
} else if (GrowSouth!=null) {
int dy=pt.y-GrowSouth.y;
zc.growCopyRectangle(0, dy);
GrowSouth=pt;
} else if (GrowNorth!=null) {
int dy=pt.y-GrowNorth.y;
zc.getCopyRectangle().translate(0, dy);
zc.growCopyRectangle(0, -dy);
GrowNorth=pt;
} else if (GrowWest!=null) {
int dx=pt.x-GrowWest.x;
zc.getCopyRectangle().translate(dx, 0);
zc.growCopyRectangle(-dx, 0);
GrowWest=pt;
} else {
zc.actualiseCopyRectangle(e);
}
zc.keepCopyRectangleInside();
showStatus(zc);
}
@Override
public void mouseReleased(final MouseEvent e, final ZirkelCanvas zc) {
DragLoc=null;
GrowEast=null;
GrowSouth=null;
GrowNorth=null;
GrowWest=null;
GrowSouthEast=null;
}
@Override
public void showStatus(final ZirkelCanvas zc) {
Rectangle r=zc.getCopyRectangle();
zc.showStatus("("+r.width+"x"+r.height+") x="+r.x+" y="+r.y);
// zc.showStatus("<html>x: <b>"+r.x+"</b></html>");
}
@Override
public boolean useSmartBoard() {
return false;
}
@Override
public void invalidate(ZirkelCanvas zc) {
zc.hideCopyRectangle();
zc.repaint();
}
}

View file

@ -0,0 +1,128 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
import eric.bar.JPropertiesBar;
import java.awt.event.MouseEvent;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.construction.Selector;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.ConstructionObject;
import rene.zirkel.objects.IntersectionObject;
import rene.zirkel.objects.PointObject;
/**
* A tool to set the the point an intersection point should stay away from or
* should come close to.
*/
public class SetAwayTool extends ObjectConstructor implements Selector{
ObjectConstructor OC;
IntersectionObject P;
boolean Away;
public SetAwayTool(final ZirkelCanvas zc, final IntersectionObject p,
final boolean away, final ObjectConstructor oc) {
P = p;
OC = oc;
P.setStrongSelected(true);
if (P.getAway()!=null){
P.getAway().setSelected(true);
}
Away = away;
zc.repaint();
}
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
final ConstructionObject o = zc.selectPoint(e.getX(), e.getY());
if (o == null)
return;
if (zc.getConstruction().dependsOn(o, P)) {
zc.warning(ConstructionObject.text1(Global.name("error.depends"), P
.getText()));
return;
}
zc.clearSelected();
P.setStrongSelected(true);
if (P.getAway()==o){
P.setAway("");
}else{
P.setAway(o.getName(), Away);
P.setUseAlpha(e.isShiftDown());
o.setSelected(true);
}
// if (P.getAway()==null) {
// P.setAway(o.getName(), Away);
// P.setUseAlpha(e.isShiftDown());
// P.getAway().setSelected(true);
// }else{
// P.setAway("");
// }
zc.validate();
// reset(zc);
JPropertiesBar.RefreshBar();
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean simple) {
zc.indicateWithSelector(e.getX(), e.getY(), this);
}
@Override
public void showStatus(final ZirkelCanvas zc) {
if (Away)
zc.showStatus(Global.name("message.setaway.away"));
else
zc.showStatus(Global.name("message.setaway.close"));
}
@Override
public void reset(final ZirkelCanvas zc) {
super.reset(zc);
zc.setTool(OC);
zc.validate();
JPropertiesBar.RefreshBar();
zc.repaint();
}
@Override
public boolean useSmartBoard() {
return false;
}
public boolean isAdmissible(ZirkelCanvas zc, ConstructionObject o) {
return (o instanceof PointObject);
}
}

View file

@ -0,0 +1,70 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
import java.awt.event.MouseEvent;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.ConstructionObject;
import rene.zirkel.objects.FunctionObject;
public class SetCurveCenterTool extends ObjectConstructor {
ObjectConstructor OC;
FunctionObject P;
public SetCurveCenterTool(final ZirkelCanvas zc, final FunctionObject p,
final ObjectConstructor oc) {
P = p;
OC = oc;
P.setSelected(true);
zc.repaint();
}
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
final ConstructionObject o = zc.selectPoint(e.getX(), e.getY());
if (o == null)
return;
P.setCenter(o.getName());
reset(zc);
}
@Override
public void showStatus(final ZirkelCanvas zc) {
zc.showStatus(Global.name("message.setcenter"));
}
@Override
public void reset(final ZirkelCanvas zc) {
super.reset(zc);
zc.setTool(OC);
zc.validate();
zc.repaint();
}
@Override
public boolean useSmartBoard() {
return false;
}
}

View file

@ -0,0 +1,125 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
// file: SetRange.java
import java.awt.event.MouseEvent;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.construction.Selector;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.AngleObject;
import rene.zirkel.objects.ConstructionObject;
import rene.zirkel.objects.ExpressionObject;
import rene.zirkel.objects.FixedAngleObject;
import rene.zirkel.objects.PointObject;
public class SetFixedAngle extends ObjectConstructor implements Selector {
ObjectConstructor OC;
FixedAngleObject A;
PointObject P1, P2, P3;
public SetFixedAngle(final ZirkelCanvas zc, final FixedAngleObject a,
final ObjectConstructor oc) {
A = a;
OC = oc;
a.setSelected(true);
zc.repaint();
}
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
if (P1 == null) {
final ConstructionObject o = zc.selectWithSelector(e.getX(), e
.getY(), this);
if (o == null)
return;
if (o instanceof PointObject) {
P1 = (PointObject) o;
P1.setSelected(true);
showStatus(zc);
zc.repaint();
} else if (o instanceof AngleObject
|| o instanceof FixedAngleObject
|| o instanceof ExpressionObject) {
A.setFixed(o.getName());
A.setDragable(false);
A.updateText();
reset(zc);
}
} else if (P2 == null) {
P2 = zc.selectPoint(e.getX(), e.getY());
if (P2 != null) {
P2.setSelected(true);
showStatus(zc);
zc.repaint();
}
} else {
P3 = zc.selectPoint(e.getX(), e.getY());
if (P3 == null)
return;
A.setFixed("a(" + P1.getName() + "," + P2.getName() + ","
+ P3.getName() + ")");
reset(zc);
}
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean simple) {
zc.indicateWithSelector(e.getX(), e.getY(), this);
}
@Override
public void showStatus(final ZirkelCanvas zc) {
if (P1 == null)
zc.showStatus(Global.name("message.setfixedangle.first"));
else if (P2 == null)
zc.showStatus(Global.name("message.setfixedangle.second"));
else
zc.showStatus(Global.name("message.setfixedangle.third"));
}
@Override
public void reset(final ZirkelCanvas zc) {
super.reset(zc);
zc.setTool(OC);
zc.validate();
zc.repaint();
}
@Override
public boolean useSmartBoard() {
return P2 != null;
}
public boolean isAdmissible(final ZirkelCanvas zc,
final ConstructionObject o) {
if ((o instanceof PointObject || o instanceof AngleObject
|| o instanceof FixedAngleObject || o instanceof ExpressionObject)
&& !zc.getConstruction().dependsOn(o, A))
return true;
return false;
}
}

View file

@ -0,0 +1,116 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
// file: SetFixedCircle.java
import java.awt.event.MouseEvent;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.construction.Selector;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.CircleObject;
import rene.zirkel.objects.ConstructionObject;
import rene.zirkel.objects.ExpressionObject;
import rene.zirkel.objects.FixedCircleObject;
import rene.zirkel.objects.PointObject;
import rene.zirkel.objects.SegmentObject;
public class SetFixedCircle extends ObjectConstructor implements Selector {
ObjectConstructor OC;
FixedCircleObject C;
PointObject P1, P2;
public SetFixedCircle(final ZirkelCanvas zc, final FixedCircleObject c,
final ObjectConstructor oc) {
C = c;
OC = oc;
c.setSelected(true);
zc.repaint();
}
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
if (P1 == null) {
final ConstructionObject o = zc.selectWithSelector(e.getX(), e
.getY(), this);
if (o == null)
return;
if (o instanceof PointObject) {
P1 = (PointObject) o;
P1.setSelected(true);
showStatus(zc);
zc.repaint();
return;
}
C.setFixed(o.getName());
C.setDragable(false);
C.updateText();
reset(zc);
} else {
P2 = zc.selectPoint(e.getX(), e.getY());
if (P2 == null)
return;
C.setFixed("d(" + P1.getName() + "," + P2.getName() + ")");
reset(zc);
}
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean simple) {
zc.indicateWithSelector(e.getX(), e.getY(), this);
}
@Override
public void showStatus(final ZirkelCanvas zc) {
if (P1 == null)
zc.showStatus(Global.name("message.setfixedcircle.first"));
else
zc.showStatus(Global.name("message.setfixedcircle.second"));
}
@Override
public void reset(final ZirkelCanvas zc) {
super.reset(zc);
zc.setTool(OC);
zc.validate();
showStatus(zc);
zc.repaint();
}
@Override
public boolean useSmartBoard() {
return P1 != null;
}
public boolean isAdmissible(final ZirkelCanvas zc,
final ConstructionObject o) {
if ((o instanceof PointObject || o instanceof SegmentObject
|| o instanceof FixedCircleObject || o instanceof CircleObject || o instanceof ExpressionObject)
&& !zc.getConstruction().dependsOn(o, C))
return true;
return false;
}
}

View file

@ -0,0 +1,127 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
// file: SetParameter.java
import eric.macros.CreateMacroPanel;
import java.awt.event.MouseEvent;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.construction.Selector;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.AngleObject;
import rene.zirkel.objects.AreaObject;
import rene.zirkel.objects.ConstructionObject;
import rene.zirkel.objects.ExpressionObject;
import rene.zirkel.objects.FunctionObject;
import rene.zirkel.objects.PointObject;
import rene.zirkel.objects.PrimitiveCircleObject;
import rene.zirkel.objects.PrimitiveLineObject;
import rene.zirkel.objects.QuadricObject;
import rene.zirkel.objects.UserFunctionObject;
/**
* Class to choose parameters for macro definition.
*
* @author Rene
*/
public class SetParameterTool extends ObjectConstructor implements Selector {
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
zc.y(e.getY());
final ConstructionObject o=zc.selectWithSelector(e.getX(), e.getY(),
this);
if (o==null) {
return;
}
if (o.isMainParameter()) {
o.setMainParameter(false);
o.setSelected(false);
zc.getConstruction().removeParameter(o);
zc.repaint();
} else {
o.setMainParameter(true);
o.setSelected(true);
zc.getConstruction().addParameter(o);
zc.repaint();
if (e.isShiftDown()) {
o.setSpecialParameter(true);
}
}
CreateMacroPanel.setParametersComments();
}
public boolean isAdmissible(final ZirkelCanvas zc,
final ConstructionObject o) {
return (o instanceof PointObject
||o instanceof PrimitiveLineObject
||o instanceof PrimitiveCircleObject
||o instanceof ExpressionObject
||o instanceof AngleObject
||o instanceof AreaObject
||o instanceof FunctionObject
||o instanceof UserFunctionObject
||o instanceof QuadricObject);
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean simple) {
zc.indicateWithSelector(e.getX(), e.getY(), this);
}
@Override
public void reset(final ZirkelCanvas zc) {
super.reset(zc);
zc.clearSelected();
zc.getConstruction().clearParameters();
}
@Override
public void showStatus(final ZirkelCanvas zc) {
zc.showStatus(Global.name("message.parameters",
"Macro Parameters: Select the Parameters!"));
}
@Override
public void setConstructionObject(ConstructionObject o, ZirkelCanvas zc) {
if (o==null) {
return;
}
if (o.isMainParameter()) {
o.setMainParameter(false);
o.setSelected(false);
zc.getConstruction().removeParameter(o);
zc.repaint();
} else {
o.setMainParameter(true);
o.setSelected(true);
zc.getConstruction().addParameter(o);
zc.repaint();
}
CreateMacroPanel.setParametersComments();
}
}

View file

@ -0,0 +1,86 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
// file: SetRange.java
import java.awt.event.MouseEvent;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.PointObject;
import rene.zirkel.objects.PrimitiveCircleObject;
public class SetRangeTool extends ObjectConstructor {
ObjectConstructor OC;
PrimitiveCircleObject C;
PointObject P1, P2;
public SetRangeTool(final ZirkelCanvas zc, final PrimitiveCircleObject c,
final ObjectConstructor oc) {
C = c;
OC = oc;
C.setSelected(true);
zc.repaint();
}
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
if (P1 == null) {
P1 = zc.selectPoint(e.getX(), e.getY());
if (P1 != null) {
P1.setSelected(true);
showStatus(zc);
zc.repaint();
}
} else {
P2 = zc.selectPoint(e.getX(), e.getY());
if (P2 == null)
return;
C.setRange(P1, P2);
reset(zc);
}
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean simple) {
zc.indicatePointObjects(e.getX(), e.getY());
}
@Override
public void showStatus(final ZirkelCanvas zc) {
if (P1 == null)
zc.showStatus(Global.name("message.range.first"));
else
zc.showStatus(Global.name("message.range.second"));
}
@Override
public void reset(final ZirkelCanvas zc) {
super.reset(zc);
zc.setTool(OC);
zc.validate();
zc.repaint();
}
}

View file

@ -0,0 +1,95 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
// file: SetParameter.java
import eric.macros.CreateMacroPanel;
import java.awt.event.MouseEvent;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.ConstructionObject;
public class SetTargetsTool extends ObjectConstructor {
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
zc.y(e.getY());
final ConstructionObject o=zc.selectConstructableObject(e.getX(), e.getY());
if (o==null||!o.isFlag()) {
return;
}
if (o.isTarget()) {
o.setTarget(false);
o.setSelected(false);
zc.getConstruction().removeTarget(o);
}else{
o.setTarget(true);
o.setSelected(true);
zc.getConstruction().addTarget(o);
}
zc.repaint();
CreateMacroPanel.setTargetsComments();
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean simple) {
zc.indicateConstructableObjects(e.getX(), e.getY());
}
@Override
public void reset(final ZirkelCanvas zc) {
super.reset(zc);
zc.clearSelected();
zc.getConstruction().clearTargets();
zc.getConstruction().determineConstructables();
}
@Override
public void showStatus(final ZirkelCanvas zc) {
zc.showStatus(Global.name("message.targets",
"Macro Targets: Select the Targets!"));
}
@Override
public boolean useSmartBoard() {
return false;
}
@Override
public void setConstructionObject(ConstructionObject o, ZirkelCanvas zc) {
if (o==null||!o.isFlag()) {
return;
}
if (o.isTarget()) {
o.setTarget(false);
o.setSelected(false);
zc.getConstruction().removeTarget(o);
}else{
o.setTarget(true);
o.setSelected(true);
zc.getConstruction().addTarget(o);
}
zc.repaint();
CreateMacroPanel.setTargetsComments();
}
}

View file

@ -0,0 +1,315 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
// file: Tracker.java
import java.awt.event.MouseEvent;
import java.util.Enumeration;
import java.util.Vector;
import rene.util.xml.XmlWriter;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.graphics.MyGraphics;
import rene.zirkel.graphics.TrackPainter;
import rene.zirkel.objects.ConstructionObject;
import rene.zirkel.objects.MoveableObject;
import rene.zirkel.objects.PointObject;
import rene.zirkel.objects.PrimitiveLineObject;
import rene.zirkel.structures.Coordinates;
public class Tracker extends ObjectConstructor implements TrackPainter {
ConstructionObject PM;
int PMax = 8, PN;
ConstructionObject P;
ConstructionObject PO[] = new ConstructionObject[PMax];
Vector V = new Vector();
Vector VO[] = new Vector[PMax];
double X, Y, DX, DY;
double XO[] = new double[PMax], YO[] = new double[PMax],
DXO[] = new double[PMax], DYO[] = new double[PMax];
boolean Started;
boolean StartedO[] = new boolean[PMax];
boolean Other;
public Tracker(final ConstructionObject p, final ConstructionObject po[]) {
super();
P = p;
PN = 0;
for (int i = 0; i < po.length; i++) {
if (i >= PMax || po[i] == null)
break;
PO[PN] = po[i];
VO[i] = new Vector();
PN++;
}
}
public Tracker() {
super();
}
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
final double x = zc.x(e.getX()), y = zc.y(e.getY());
if (P == null) {
P = zc.selectPoint(e.getX(), e.getY());
if (P == null)
P = zc.selectLine(e.getX(), e.getY());
if (P == null)
return;
P.setSelected(true);
zc.repaint();
if (e.isShiftDown())
Other = true;
else
Other = false;
showStatus(zc);
} else if (Other) {
ConstructionObject P = zc.selectPoint(e.getX(), e.getY());
if (P == null)
P = zc.selectLine(e.getX(), e.getY());
if (P != null) {
P.setSelected(true);
zc.repaint();
PO[PN] = P;
VO[PN] = new Vector();
PN++;
}
if (!e.isShiftDown() || PN >= PMax)
Other = false;
showStatus(zc);
} else {
final ConstructionObject pm = zc.selectMoveableObject(e.getX(), e
.getY());
PM = pm;
if (PM != null) {
zc.clearSelected();
PM.setSelected(true);
((MoveableObject) PM).startDrag(x, y);
zc.repaint();
showStatus(zc);
}
Started = false;
}
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean simple) {
if (P == null || Other)
zc.indicatePointsOrLines(e.getX(), e.getY());
else if (PM == null)
zc.indicateMoveableObjects(e.getX(), e.getY());
else
zc.clearIndicated();
}
@Override
public void mouseDragged(final MouseEvent e, final ZirkelCanvas zc) {
if (PM == null)
return;
((MoveableObject) PM).dragTo(zc.x(e.getX()), zc.y(e.getY()));
zc.validate();
track(zc);
zc.repaint();
}
@Override
public void mouseReleased(final MouseEvent e, final ZirkelCanvas zc) {
if (PM == null)
return;
PM.setSelected(false);
PM = null;
zc.repaint();
showStatus(zc);
}
@Override
public void reset(final ZirkelCanvas zc) {
zc.clearSelected();
P = PM = null;
PN = 0;
V = new Vector();
showStatus(zc);
zc.repaint();
}
@Override
public void showStatus(final ZirkelCanvas zc) {
if (P == null || Other)
zc.showStatus(Global.name("message.tracker.select"));
else if (PM == null)
zc.showStatus(Global.name("message.tracker.selectpoint"));
else
zc.showStatus(Global.name("message.tracker.move"));
}
public void track(final ZirkelCanvas zc) {
if (P == null)
return;
if (P instanceof PointObject) {
final PointObject p = (PointObject) P;
if (p.valid())
V.addElement(new Coordinates(p.getX(), p.getY()));
} else if (P instanceof PrimitiveLineObject) {
final PrimitiveLineObject L = (PrimitiveLineObject) P;
if (L.valid()) {
if (!Started) {
X = L.getX();
Y = L.getY();
DX = L.getDX();
DY = L.getDY();
Started = true;
} else {
double x, y, dx, dy;
x = L.getX();
y = L.getY();
dx = L.getDX();
dy = L.getDY();
final double det = dx * DY - dy * DX;
if (Math.sqrt(Math.abs(det)) > 1e-9) {
final double a = (-(X - x) * DY + DX * (Y - y))
/ (-det);
V.addElement(new Coordinates(x + a * dx, y + a * dy));
}
X = x;
Y = y;
DX = dx;
DY = dy;
}
}
}
for (int i = 0; i < PN; i++) {
if (PO[i] == null || !PO[i].valid())
continue;
if (PO[i] instanceof PointObject) {
final PointObject p = (PointObject) PO[i];
VO[i].addElement(new Coordinates(p.getX(), p.getY()));
} else if (PO[i] instanceof PrimitiveLineObject) {
final PrimitiveLineObject L = (PrimitiveLineObject) PO[i];
if (!StartedO[i]) {
XO[i] = L.getX();
YO[i] = L.getY();
DXO[i] = L.getDX();
DYO[i] = L.getDY();
StartedO[i] = true;
} else {
double x, y, dx, dy;
x = L.getX();
y = L.getY();
dx = L.getDX();
dy = L.getDY();
final double det = dx * DYO[i] - dy * DXO[i];
if (Math.sqrt(Math.abs(det)) > 1e-9) {
final double a = (-(XO[i] - x) * DYO[i] + DXO[i]
* (YO[i] - y))
/ (-det);
VO[i]
.addElement(new Coordinates(x + a * dx, y + a
* dy));
}
XO[i] = x;
YO[i] = y;
DXO[i] = dx;
DYO[i] = dy;
}
}
}
}
public Enumeration elements() {
return V.elements();
}
public void paint(final MyGraphics g, final ZirkelCanvas zc) {
if (P == null)
return;
Coordinates C;
Enumeration e = V.elements();
g.setColor(P);
double c0, r0, c, r;
final int maxd = zc.width() / 20;
if (e.hasMoreElements()) {
C = (Coordinates) e.nextElement();
c0 = zc.col(C.X);
r0 = zc.row(C.Y);
while (e.hasMoreElements()) {
C = (Coordinates) e.nextElement();
c = zc.col(C.X);
r = zc.row(C.Y);
if (Math.abs(c0 - c) < maxd && Math.abs(r0 - r) < maxd)
g.drawLine(c0, r0, c, r, P);
else
g.drawLine(c0, r0, c0, r0, P);
c0 = c;
r0 = r;
}
}
for (int i = 0; i < PN; i++) {
if (PO[i] == null)
continue;
g.setColor(PO[i]);
e = VO[i].elements();
if (e.hasMoreElements()) {
C = (Coordinates) e.nextElement();
c0 = zc.col(C.X);
r0 = zc.row(C.Y);
while (e.hasMoreElements()) {
C = (Coordinates) e.nextElement();
c = zc.col(C.X);
r = zc.row(C.Y);
if (Math.abs(c0 - c) < maxd && Math.abs(r0 - r) < maxd)
g.drawLine(c0, r0, c, r, PO[i]);
else
g.drawLine(c0, r0, c0, r0, PO[i]);
c0 = c;
r0 = r;
}
}
}
}
public void validate(final ZirkelCanvas zc) {
}
public void save(final XmlWriter xml) {
if (P == null)
return;
xml.startTagStart("Track");
xml.printArg("track", P.getName());
for (int i = 0; i < PN; i++) {
xml.printArg("track" + i, PO[i].getName());
}
if (PM != null)
xml.printArg("move", PM.getName());
xml.finishTagNewLine();
}
@Override
public boolean useSmartBoard() {
return false;
}
}

View file

@ -0,0 +1,203 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
// file: Tracker.java
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.util.Enumeration;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.graphics.MyGraphics;
import rene.zirkel.graphics.MainGraphics;
import rene.zirkel.objects.ConstructionObject;
import rene.zirkel.objects.PointObject;
import rene.zirkel.objects.PrimitiveCircleObject;
public class UniversalTracker extends javax.swing.JPanel {
/**
*
*/
private static final long serialVersionUID = 1L;
public BufferedImage TrackI = null;
public MyGraphics TrackIG = null;
int IW = 0, IH = 0;
double DX = 0, Xmin = 0, Ymin = 0;
boolean isActive = false;
ZirkelCanvas ZC;
public UniversalTracker(final ZirkelCanvas zc) {
ZC = zc;
}
public void setActive(final boolean b) {
isActive = b;
}
public boolean isActive() {
return isActive;
}
public void clearTrackObjects() {
final Enumeration e = ZC.getConstruction().V.elements();
while (e.hasMoreElements()) {
final ConstructionObject o = (ConstructionObject) e.nextElement();
o.setTracked(false);
}
isActive = false;
}
public synchronized void draw() {
if (TrackI == null) {
return;
}
if (!isActive) {
return;
}
// in case of zoom or coordinates system move :
if ((ZC.DX != DX) || (ZC.Xmin != Xmin) || (ZC.Ymin != Ymin)) {
IW = ZC.IW;
IH = ZC.IH;
DX = ZC.DX;
Xmin = ZC.Xmin;
Ymin = ZC.Ymin;
clearTrackImage();
}
ZC.I.getGraphics().drawImage(TrackI, 0, 0, this);
}
public void createTrackImage() {
IW = ZC.IW;
IH = ZC.IH;
DX = ZC.DX;
Xmin = ZC.Xmin;
Ymin = ZC.Ymin;
TrackI = new BufferedImage(IW, IH, BufferedImage.TYPE_INT_ARGB);
clearTrackImage();
TrackIG = new MainGraphics((Graphics2D)TrackI.getGraphics(), ZC);
}
public void clearTrackImage() {
final Graphics2D g2D = TrackI.createGraphics();
g2D
.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR,
0.0f));
final Rectangle2D.Double rect = new Rectangle2D.Double(0, 0, IW, IH);
g2D.fill(rect);
}
public void drawTrackCircle(final PrimitiveCircleObject o, final double d,
final double d0, final double r) {
isActive = true;
TrackIG.setColor(o);
TrackIG.drawCircle(d, d0, r, o);
}
public void drawTrackLine(final ConstructionObject o, final double c1,
final double r1, final double c2, final double r2) {
isActive = true;
TrackIG.setColor(o);
TrackIG.drawLine(c1, r1, c2, r2, o);
}
public void drawTrackPoint(final ConstructionObject o, final double X,
final double Y, final int type) {
isActive = true;
if (TrackIG == null) {
return;
}
double size = ZC.pointSize();
if (size < 1) {
size = 1;
}
final double r = ZC.col(X), c = ZC.row(Y);
if (o.visible(ZC)) {
final boolean ind = o.indicated();
final boolean sel = o.selected();
o.setIndicated(false);
o.setSelected(false);
switch (type) {
case PointObject.SQUARE:
final double sx = r - size - 1,
sy = c - size - 1,
sw = 2 * size + 2;
if (o.getColorType() == ConstructionObject.THICK) {
TrackIG.fillRect(sx, sy, sw, sw, true, false, o);
} else {
TrackIG.fillRect(sx, sy, sw, sw, new Color(250, 250, 250));
}
TrackIG.setColor(o);
TrackIG.drawRect(sx, sy, sw, sw);
break;
case PointObject.DIAMOND:
final double dx = r - size - 2,
dy = c - size - 2,
dw = 2 * size + 4;
TrackIG.drawDiamond(dx, dy, dw,
(o.getColorType() == ConstructionObject.THICK), o);
break;
case PointObject.CIRCLE:
final double cx = r - size - 1,
cy = c - size - 1,
cw = 2 * size + 2;
if (o.getColorType() == ConstructionObject.THICK) {
TrackIG.fillOval(cx, cy, cw, cw, true, false, o);
} else {
TrackIG.fillOval(cx, cy, cw, cw, new Color(250, 250, 250));
TrackIG.setColor(o);
TrackIG.drawOval(cx, cy, cw, cw);
}
break;
case PointObject.DOT:
if (o.getColorType() == ConstructionObject.THICK) {
TrackIG.fillRect(r, c, 1, 1, true, false, o);
} else {
TrackIG.fillRect(r, c, 1, 1, false, false, o);
// TrackIG.drawLine(r, c, r, c);
}
break;
case PointObject.CROSS:
if (o.getColorType() == ConstructionObject.THICK) {
TrackIG.drawThickLine(r - size, c, r + size, c);
TrackIG.drawThickLine(r, c - size, r, c + size);
} else {
TrackIG.drawLine(r - size, c, r + size, c);
TrackIG.drawLine(r, c - size, r, c + size);
}
break;
case PointObject.DCROSS:
final double dcx = r - size - 1,
dcy = c - size - 1,
dcw = 2 * size + 1;
TrackIG.drawDcross(dcx, dcy, dcw,
(o.getColorType() == ConstructionObject.THICK), o);
break;
}
o.setIndicated(ind);
o.setSelected(sel);
}
}
}

View file

@ -0,0 +1,212 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
// file: Hider.java
import java.awt.Cursor;
import java.awt.event.MouseEvent;
import java.util.Enumeration;
import rene.gui.Global;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.construction.Construction;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.ConstructionObject;
import rene.zirkel.objects.ExpressionObject;
import rene.zirkel.objects.MoveableObject;
import rene.zirkel.objects.TextObject;
import rene.zirkel.objects.UserFunctionObject;
/**
* @author Rene Werkzeug zum Zoomen des Fensters und zum Verschieben.
* Verschieben funktioniert im Zentrum des Fensters.
*/
public class ZoomerTool extends ObjectConstructor {
boolean Dragging = false, Zoom = false;
double X, Y, W, X0, Y0;
ObjectConstructor OC;
public static void initNonDraggableObjects(final Construction c) {
final Enumeration en = c.elements();
while (en.hasMoreElements()) {
final ConstructionObject o = (ConstructionObject) en.nextElement();
if ((o instanceof TextObject) || (o instanceof ExpressionObject)
|| (o instanceof UserFunctionObject)) {
final MoveableObject mo = (MoveableObject) o;
mo.startDrag(0, 0);
}
}
}
public static void shiftNonDraggableObjectsBy(final Construction c,
final double dx, final double dy) {
final Enumeration en = c.elements();
while (en.hasMoreElements()) {
final ConstructionObject o = (ConstructionObject) en.nextElement();
if ((o instanceof TextObject) || (o instanceof ExpressionObject)
|| (o instanceof UserFunctionObject)) {
final MoveableObject mo = (MoveableObject) o;
mo.dragTo(dx, dy);
}
// else if (!o.isKeepClose()) {
//
// System.out.println("dx="+dx);
// o.setcOffset(o.xcOffset()+2*dx, o.ycOffset()+2*dy);
//
// // C.setXYW(C.getX()+dx*C.getW(), C.getY()+dy*C.getW(),
// C.getW());
//
// };
}
}
public static void zoomNonDraggableObjectsBy(final Construction c,
final double f) {
final Enumeration en = c.elements();
while (en.hasMoreElements()) {
final ConstructionObject o = (ConstructionObject) en.nextElement();
if ((o instanceof TextObject) || (o instanceof ExpressionObject)
|| (o instanceof UserFunctionObject)) {
final MoveableObject mo = (MoveableObject) o;
mo.move(c.getX() + (mo.getOldX() - c.getX()) * f, c.getY()
+ (mo.getOldY() - c.getY()) * f);
}
}
}
public ZoomerTool() {
super();
}
public ZoomerTool(final ObjectConstructor oc, final MouseEvent e,
final ZirkelCanvas zc) {
super();
OC = oc;
X0 = zc.x(e.getX());
Y0 = zc.y(e.getY());
final Construction c = zc.getConstruction();
X = c.getX();
Y = c.getY();
W = c.getW();
Zoom = false;
zc.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
Dragging = true;
initNonDraggableObjects(c);
}
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
X0 = zc.x(e.getX());
Y0 = zc.y(e.getY());
final Construction c = zc.getConstruction();
X = c.getX();
Y = c.getY();
W = c.getW();
Zoom = (Math.abs(X - X0) > W / 4 || Math.abs(Y - Y0) > W / 4);
if (!Zoom) {
zc.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
}
Dragging = true;
OC = null;
initNonDraggableObjects(c);
}
@Override
public void mouseDragged(final MouseEvent e, final ZirkelCanvas zc) {
if (!Dragging) {
return;
}
final Construction c = zc.getConstruction();
c.setXYW(X, Y, W);
zc.recompute();
final double x = zc.x(e.getX()), y = zc.y(e.getY());
if (Zoom) {
final double f = Math.sqrt((X0 - X) * (X0 - X) + (Y0 - Y)
* (Y0 - Y))
/ Math.sqrt((x - X) * (x - X) + (y - Y) * (y - Y));
c.setXYW(X, Y, f * W);
zoomNonDraggableObjectsBy(c, f);
} else {
c.setXYW(X - (x - X0), Y - (y - Y0), W);
shiftNonDraggableObjectsBy(c, X0 - x, Y0 - y);
}
zc.recompute();
zc.validate();
zc.repaint();
}
@Override
public void mouseReleased(final MouseEvent e, final ZirkelCanvas zc) {
Dragging = Zoom = false;
zc.setCursor(Cursor.getDefaultCursor());
zc.recompute();
zc.validate();
zc.repaint();
if (OC != null) {
zc.setTool(OC);
}
}
@Override
public void showStatus(final ZirkelCanvas zc) {
zc.showStatus(Global.name("message.zoom"));
}
@Override
public void reset(final ZirkelCanvas zc) {
zc.clearSelected();
zc.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
Zoom = Dragging = false;
}
@Override
public void invalidate(final ZirkelCanvas zc) {
zc.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean flag) {
X0 = zc.x(e.getX());
Y0 = zc.y(e.getY());
final Construction c = zc.getConstruction();
X = c.getX();
Y = c.getY();
W = c.getW();
Zoom = (Math.abs(X - X0) > W / 4 || Math.abs(Y - Y0) > W / 4);
if (!Zoom) {
zc.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
} else {
zc.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
}
@Override
public boolean useSmartBoard() {
return false;
}
}

View file

@ -0,0 +1,68 @@
/*
Copyright 2006 Rene Grothmann, modified by Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a 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, version 3 of the License.
C.a.R. 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package rene.zirkel.tools;
// file: Binder.java
import java.awt.event.MouseEvent;
import rene.zirkel.ZirkelCanvas;
import rene.zirkel.construction.Selector;
import rene.zirkel.constructors.ObjectConstructor;
import rene.zirkel.objects.ConstructionObject;
public class nullTool extends ObjectConstructor implements Selector {
ObjectConstructor OC;
String MSG;
String TYPE;
public nullTool(final ZirkelCanvas zc, final ObjectConstructor oc) {
OC=oc;
zc.repaint();
}
@Override
public void mousePressed(final MouseEvent e, final ZirkelCanvas zc) {
}
@Override
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc,
final boolean simple) {
}
public boolean isAdmissible(final ZirkelCanvas zc,
final ConstructionObject o) {
return false;
}
@Override
public void showStatus(final ZirkelCanvas zc) {
// zc.showStatus(MSG);
}
@Override
public void reset(final ZirkelCanvas zc) {
super.reset(zc);
zc.setTool(OC);
zc.validate();
zc.repaint();
}
}