Commit 8a85dabc authored by Samy Khadem-Al-Charieh's avatar Samy Khadem-Al-Charieh
Browse files

initial import into IfM's Subversion

git-svn-id: https://svn.math.tu-berlin.de/svn/jtem@1 f5b180c5-49ee-4939-b20e-b6ed35f0f7b7
parents
lib: cls
cd classes; jar cf ../moebiusViewer.jar `find . -name '*.class'`
cls:
if [ ! -d classes ]; then mkdir classes; fi
javac -classpath `echo lib/*.jar|tr \ :` -d classes/ \
`find src -name '*.java'`
javadoc:
if [ ! -d javadocs ]; then mkdir javadocs; fi
javadoc -d javadocs -classpath classes:`echo lib/*.jar|tr \ :` -sourcepath src -protected \
-windowtitle "moebiusViewer documentation" -doctitle "moebiusViewer" \
-nodeprecated -nodeprecatedlist `find src/moebiusViewer -type d -a ! -name CVS | sed -e 'y/\//./' -e 's/src\.\(.*\)/\1/'`
clean:
rm -f `find src -name "*.class"`
if [ -e moebiusViewer.jar ]; then rm -f moebiusViewer.jar; fi
if [ -d classes ]; then rm -fr classes; fi
if [ -d javadocs ]; then rm -fr javadocs; fi
*** Installation
Type make to build the moebiusViewer.jar and put it in your classpath. If you
haven't already included mfc.jar and numericalMethods.jar to your classpath
add these two archives in the lib directory too.
*** oorange nodes
The nodes directory contains various example nodes.
*** Building and Cleanup
The Makefile supports the following targets:
lib (the default)
Create the file moebiusViewer.jar.
cls
Compile the classes only. Do not build the library.
javadoc
Generate documentation for the core features.
Note that javadoc prior to 1.4b2 does not generate the package overview.
NOTE: The documentation is linked against the java documentation from sun.
This should be changed before generating docs if a local mirror should be used.
clean:
remove the library file moebiusViewer.jar and the generated classes and
documentation.
<html><body>
</body></html>
// JTEM - Java Tools for Experimental Mathematics
// Copyright (C) 2001 JEM-Group
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/*--- formatted by Jindent 2.1, (www.c-lab.de/~jindent) ---*/
package de.jtem.moebiusViewer;
import de.jtem.moebiusViewer.shape.Rectangle;
public abstract class AbstractBounder extends MoebiusGraphics {
static final private long serialVersionUID = 246483960508554831L;
boolean bounded = false;
public Rectangle bound = new Rectangle ();
public Rectangle getBound () {
if (bounded) {
return new Rectangle (bound);
}
else {
return null;
}
}
public void add (Rectangle aBound) {
if (bounded) {
bound.unify (aBound);
}
else {
bound.set (aBound);
}
bounded = true;
}
public boolean isBounded () {
return bounded;
}
public void setBounded (boolean aBool) {
bounded = aBool;
}
public void initBounding () {
setBounded (false);
}
public Rectangle getBound (MoebiusShape aShape) {
Rectangle tmpBound = bound;
Rectangle result = new Rectangle ();
bound = result;
clear();
push (aShape);
initBounding ();
aShape.draw (this);
popShape ();
bound = tmpBound;
return result;
}
}
// JTEM - Java Tools for Experimental Mathematics
// Copyright (C) 2001 JEM-Group
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/*--- formatted by Jindent 2.1, (www.c-lab.de/~jindent) ---*/
package de.jtem.moebiusViewer;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.FontMetrics;
import de.jtem.mfc.geometry.ComplexProjective1;
import de.jtem.mfc.field.Complex;
public abstract class AbstractDrawer extends MoebiusGraphicsWithPrimitives {
private static final long serialVersionUID = 938786947638905884L;
private ComplexProjective1 tu = new ComplexProjective1();
private Complex u = new Complex();
public AbstractPSWriter getPSWriter() {
return null;
}
public void draw( Graphics G, MoebiusShape aShape ) {
clear();
setGraphics(G);
push (aShape);
aShape.draw (this);
popShape ();
}
public void draw( Graphics G, MoebiusTool aTool ) {
setGraphics (G);
aTool.draw (this);
}
public void drawColor( Color color ) {
getGraphics().setColor( color );
}
public void drawCircle(double x, double y, double radius ) {
if( radius == 0 ) return;
getGraphics().drawOval( (int)(x-radius),
size.height - (int)(y + radius),
2*(int)radius, 2*(int)radius);
}
public void drawLine(double x1, double y1, double x2, double y2) {
getGraphics().drawLine( (int)x1, size.height - (int)y1, (int)x2, size.height -(int)y2);
}
public void drawArc( double x, double y,
double radius, double startAngle, double arcAngle ) {
getGraphics().drawArc
( (int)(x-radius), size.height - (int)(y + radius),
2*(int)radius, 2*(int)radius, (int)startAngle, (int)arcAngle);
}
public void drawString(String s, double x, double y) {
drawColor(attributes.color);
FontMetrics fontMetrics = getGraphics().getFontMetrics(); //uhhh
double xPos, yPos;
switch (attributes.horizontalTextLayout) {
case Attributes.CENTER:
xPos = x - fontMetrics.stringWidth(s) / 2;
break;
case Attributes.RIGHT:
xPos = x - fontMetrics.stringWidth(s);
break;
case Attributes.LEFT:
default:
xPos = x;
}
switch (attributes.verticalTextLayout) {
case Attributes.CENTER:
yPos = y + fontMetrics.getDescent() / 2
- fontMetrics.getAscent() / 2;
break;
case Attributes.BOTTOM:
yPos = y + fontMetrics.getDescent();
break;
case Attributes.BASE:
default:
yPos = y;
break;
case Attributes.TOP:
yPos = y - fontMetrics.getAscent();
}
getGraphics().drawString( s, (int)xPos, size.height - (int)yPos );
}
public void fillColor( Color color ) {
getGraphics().setColor( color );
}
public void fillCircle( double x, double y, double radius ) {
if( radius == 0 ) return;
getGraphics().fillOval( (int)(x-radius),
size.height - (int)(y + radius),
2*(int)radius, 2*(int)radius);
}
public void fillPolygon( double[] xPoints, double[] yPoints, int nPoints ) {
int n = yPoints.length;
int [] newXPoints = new int[n];
int [] newYPoints = new int[n];
for (int i=0; i<n; i++) {
newXPoints[i] = (int)(xPoints[i] + 0.5);
newYPoints[i] = size.height - (int)(yPoints[i]+0.5);
}
getGraphics().fillPolygon( newXPoints, newYPoints, nPoints );
}
}
// JTEM - Java Tools for Experimental Mathematics
// Copyright (C) 2001 JEM-Group
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/*--- formatted by Jindent 2.1, (www.c-lab.de/~jindent) ---*/
package de.jtem.moebiusViewer;
import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.io.File;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.Vector;
import de.jtem.mfc.field.Complex;
import de.jtem.mfc.geometry.ComplexProjective1;
import de.jtem.moebiusViewer.shape.Rectangle;
public abstract class AbstractPSWriter extends MoebiusGraphicsWithPrimitives {
private static final long serialVersionUID = 1L;
protected double[] p = new double[4];
protected double[] tp = new double[4];
MoebiusShape shape;
float lineWidth = 1;
protected PrintWriter writer;
String creator = "moebius viewer 2d";
String title = "";
protected Rectangle bound = new Rectangle( 0, 0, 100, 100 );
static Vector fontNames = new Vector ();
static {
fontNames.addElement ("SansSerif");
fontNames.addElement ("Serif");
fontNames.addElement ("Monospaced");
}
private ComplexProjective1 tu = new ComplexProjective1();
private Complex u = new Complex();
private float[] colorComp = new float[3];
static String reference =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890";
static String prolog = "%%BeginProlog\n"
+ "/BD {bind def} bind def\n" + "/D {def} BD\n" + "/ISOF {\n"
+ " dup findfont dup length 1 add dict begin {\n"
+ " 1 index /FID eq {pop pop} {D} ifelse\n"
+ " } forall /Encoding ISOLatin1Encoding D\n"
+ " currentdict end definefont\n" + "} BD\n" + "/F [\n"
+ " /Helvetica ISOF\n" + " /Helvetica-Bold ISOF\n"
+ " /Helvetica-Oblique ISOF\n" + " /Helvetica-BoldOblique ISOF\n"
+ " /Helvetica ISOF\n" + " /Helvetica-Bold ISOF\n"
+ " /Helvetica-Oblique ISOF\n" + " /Helvetica-BoldOblique ISOF\n"
+ " /Times-Roman ISOF\n" + " /Times-Bold ISOF\n"
+ " /Times-Italic ISOF\n" + " /Times-BoldItalic ISOF\n"
+ " /Courier ISOF\n" + " /Courier-Bold ISOF\n"
+ " /Courier-Oblique ISOF\n" + " /Courier-BoldOblique ISOF\n"
+ "] D\n" + "/SF {\n" + " F exch get exch scalefont setfont\n" + " ("
+ reference + ") stringwidth pop div\n"
+ " currentfont exch scalefont setfont} BD\n" + "%%EndProlog";
public void setFont (Font f) {
if (f.equals (attributes.font)) {
return;
}
super.setFont (f);
writeFont ();
}
protected final void writeFont () {
writer.println (getWidthOfReference (attributes.font) + " "
+ attributes.font.getSize () + " "
+ getFontIndex (attributes.font) + " SF");
}
protected final double getWidthOfReference (Font aFont) {
FontMetrics fontMetrics = getGraphics ().getFontMetrics (aFont);
return fontMetrics.stringWidth (reference);
}
protected final int getFontIndex (Font aFont) {
return fontNames.indexOf (aFont.getName ()) * 4 + 4 + aFont.getStyle ();
}
final void writeColor( Color color ) {
writer.println ((((float)color.getRed () ) / 255) + " " +
(((float)color.getGreen ()) / 255) + " " +
(((float)color.getBlue () ) / 255) + " setrgbcolor");
}
final void writeLineWidth( float lineWidth ) {
if(this.lineWidth == lineWidth) return;
this.lineWidth = lineWidth;
writer.println ( lineWidth + " setlinewidth");
}
public AbstractPSWriter( Attributes att ) {
super();
setAttributes (att);
}
public MoebiusShape getShape() {
return shape;
}
public void setShape( MoebiusShape shape ) {
this.shape = shape;
}
public Rectangle getBound() {
return bound;
}
public void setBound( Rectangle bound ) {
this.bound = bound;
}
public String getCreator () {
return creator;
}
public void setCreator( String creator ) {
this.creator = creator;
}
public String getTitle () {
return title;
}
public void setTitle( String title ) {
this.title = title;
}
public void write( File aFile ) {
try {
FileOutputStream out = new FileOutputStream (aFile);
writer = new PrintWriter (out);
writer.println ("%!PS-Adobe-2.0 EPSF-1.2");
writer.println ("%%Pages: 1");
writer.println ("%%BoundingBox: "
+ bound.x + " " + bound.y + " "
+ (bound.x + bound.w) + " " + (bound.y+bound.h) );
writer.println ("%%Creator: (" + creator + ")");
writer.println ("%%Title: " + title);
writer.println ("%%EndComments");
writer.println (prolog);
writer.println ("1 setlinecap");
writer.println ("1 setlinejoin");
writer.println ("1 setlinewidth");
writeFont ();
writeColor( attributes.color );
writer.println ("newpath");
writer.println ( bound.x + " " + bound.y + " moveto");
writer.println ((bound.x + bound.w) + " " + bound.y + " lineto");
writer.println ((bound.x + bound.w) + " " + (bound.y + bound.h) + " lineto");
writer.println ( bound.x + " " + (bound.y + bound.h) + " lineto");
writer.println ("closepath");
writer.println ("clip");
if( shape != null )
shape.draw (this);
else
drawString( "empty scene", bound.x + bound.w / 2, bound.y + bound.h / 2 );
//writer.println ("%%PSTrailer\n%end\ngrestore");
writer.println ("%%PSTrailer\n%end\n");
writer.close ();
out.close ();
}
catch (java.io.IOException io) {
System.err.println (io);
return;
}
}
protected final float x (double aX) {
return (float) aX;
}
protected final float y (double aY) {
return (float) (aY); //(bound.h + 2 * bound.y - aY);
}
public void drawColor( Color color ) {
writeColor( color );
}
public void drawCircle(double x, double y, double radius ) {
if( radius == 0 ) return;
writeLineWidth( (float)this.attributes.lineWidth );
writer.println ("newpath");
writer.println( x(x) + " " + y(y) + " " + (float)radius + " 0 360 arc ");
writer.println ("closepath");
writer.println ("stroke");
}
public void drawLine(double x1, double y1, double x2, double y2) {
writeLineWidth( (float)this.attributes.lineWidth );
writer.println ("newpath");
writer.println ( x(x1) + " " + y(y1) + " moveto");
writer.println ( x(x2) + " " + y(y2) + " lineto");
writer.println ("stroke");
}
public void drawArc(double x, double y, double radius,
double startAngle, double arcAngle) {
if( radius == 0 ) return;
writeLineWidth( (float)this.attributes.lineWidth );
writer.println ("newpath");
writer.println( x(x) + " " + y(y) + " " + (float)radius + " "
+ Math.min( startAngle, startAngle+arcAngle ) + " "
+ Math.max( startAngle, startAngle+arcAngle ) + " arc ");
writer.println ("stroke");
}
public void drawString( String str, double x, double y) {
writer.println( x(x) + " " + y(y) + " moveto ");
writer.println ("(" + str + ") show");
}
public void fillColor( Color color ) {
writeColor( color );
}
public void fillCircle( double x, double y, double radius ) {
if( radius == 0 ) return;
writer.println ("newpath");
writer.println( x(x) + " " + y(y) + " " + (float)radius + " 0 360 arc ");
writer.println ("closepath");
writer.println ("fill");
}
public void fillPolygon( double [] x, double [] y, int nPoints ) {
writer.println ("newpath");
writer.println ( x(x[0]) + " " + y(y[0]) + " moveto");
for( int i=1; i<nPoints; i++ )
writer.println ( x(x[i]) + " " + y(y[i]) + " lineto");
writer.println ("closepath");
writer.println ("fill");
}
}
// JTEM - Java Tools for Experimental Mathematics
// Copyright (C) 2001 JEM-Group
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/*--- formatted by Jindent 2.1, (www.c-lab.de/~jindent) ---*/
package de.jtem.moebiusViewer;
import java.awt.event.MouseEvent;
import de.jtem.moebiusViewer.util.MoebiusShapeStack;