created mirror
This commit is contained in:
167
Java/arch/java2d/ZZDrawingJ2D.java
Normal file
167
Java/arch/java2d/ZZDrawingJ2D.java
Normal file
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
ZZDrawingJ2D.java
|
||||
*
|
||||
* Copyright (c) 2000, Ted Nelson and Tuomas Lukka
|
||||
*
|
||||
* You may use and distribute under the terms of either the GNU Lesser
|
||||
* General Public License, either version 2 of the license or,
|
||||
* at your choice, any later version. Alternatively, you may use and
|
||||
* distribute under the terms of the XPL.
|
||||
*
|
||||
* See the LICENSE.lgpl and LICENSE.xpl files for the specific terms of
|
||||
* the licenses.
|
||||
*
|
||||
* This software 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 README
|
||||
* file for more details.
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Written by Tuomas Lukka
|
||||
*/
|
||||
package org.gzigzag;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.*;
|
||||
|
||||
/** An implementation of ZZDrawing for the Java2D API.
|
||||
* This allows us to use Java2D's features if present, but
|
||||
* not to depend on them.
|
||||
*/
|
||||
|
||||
public class ZZDrawingJ2D extends ZZDrawing {
|
||||
public static final String rcsid = "$Id: ZZDrawingJ2D.java,v 1.21 2001/03/26 12:41:00 tjl Exp $";
|
||||
|
||||
public String getType() {
|
||||
return "Java2D: antialias, alpha(if used), rotation";
|
||||
}
|
||||
|
||||
public void setAlpha(Graphics g0, float alpha) {
|
||||
Graphics2D g = (Graphics2D)g0;
|
||||
g.setComposite(AlphaComposite.getInstance(
|
||||
AlphaComposite.SRC_OVER, alpha));
|
||||
}
|
||||
|
||||
public RenderingHints qualityHints = new RenderingHints(null);
|
||||
{
|
||||
qualityHints.put(
|
||||
RenderingHints.KEY_TEXT_ANTIALIASING,
|
||||
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
||||
|
||||
qualityHints.put(
|
||||
RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
qualityHints.put(RenderingHints.KEY_RENDERING,
|
||||
RenderingHints.VALUE_RENDER_QUALITY);
|
||||
qualityHints.put(RenderingHints.KEY_STROKE_CONTROL,
|
||||
RenderingHints.VALUE_STROKE_PURE);
|
||||
|
||||
// qualityHints.put(RenderingHints.KEY_FRACTIONALMETRICS,
|
||||
// RenderingHints.VALUE_FRACTIONALMETRICS_ON);
|
||||
|
||||
}
|
||||
public RenderingHints speedHints = new RenderingHints(null);
|
||||
{
|
||||
speedHints.put(RenderingHints.KEY_RENDERING,
|
||||
RenderingHints.VALUE_RENDER_SPEED);
|
||||
}
|
||||
|
||||
public void setFIXME(boolean t) {
|
||||
if (t) {
|
||||
qualityHints.put(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
qualityHints.put(RenderingHints.KEY_RENDERING,
|
||||
RenderingHints.VALUE_RENDER_QUALITY);
|
||||
qualityHints.put(RenderingHints.KEY_STROKE_CONTROL,
|
||||
RenderingHints.VALUE_STROKE_PURE);
|
||||
}
|
||||
else {
|
||||
qualityHints.put(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_OFF);
|
||||
qualityHints.put(RenderingHints.KEY_RENDERING,
|
||||
RenderingHints.VALUE_RENDER_SPEED);
|
||||
qualityHints.put(RenderingHints.KEY_STROKE_CONTROL,
|
||||
RenderingHints.VALUE_STROKE_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean enableQuality(boolean t) {
|
||||
super.enableQuality(t);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setQuality(Graphics g0) {
|
||||
Graphics2D g = (Graphics2D)g0;
|
||||
if (qualityEnabled()) g.setRenderingHints(qualityHints);
|
||||
else g.setRenderingHints(speedHints);
|
||||
}
|
||||
|
||||
public void setDefaults(Graphics g0) {
|
||||
//Graphics2D g = (Graphics2D)g0;
|
||||
//g.rotate(0.1);
|
||||
}
|
||||
|
||||
/** A flob which shows the given ZZScene rotated by given angle.
|
||||
*/
|
||||
public class RotatedSceneFlob extends SceneFlob {
|
||||
|
||||
double rot;
|
||||
|
||||
public RotatedSceneFlob(int x, int y, int d, int w, int h, ZZCell c, FlobSet sc,
|
||||
double rot) {
|
||||
super(x,y,d,w,h,c, sc);
|
||||
this.rot = rot;
|
||||
}
|
||||
|
||||
|
||||
public void transform(double[] srcPtr, double[]dstPts, boolean toExt) {
|
||||
AffineTransform tr =
|
||||
AffineTransform.getRotateInstance(rot, x+w/2, y+h/2);
|
||||
try {
|
||||
if(toExt)
|
||||
tr.transform(srcPtr, 0, dstPts, 0, srcPtr.length);
|
||||
else
|
||||
tr.inverseTransform(srcPtr, 0, dstPts, 0, srcPtr.length);
|
||||
} catch(Exception e) {
|
||||
ZZLogger.exc(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Point transform(Point src, Point dst, boolean toExt) {
|
||||
AffineTransform tr =
|
||||
AffineTransform.getRotateInstance(rot, x+w/2, y+h/2);
|
||||
try {
|
||||
if(toExt)
|
||||
tr.transform(src, dst);
|
||||
else
|
||||
tr.inverseTransform(src, dst);
|
||||
} catch(Exception e) {
|
||||
ZZLogger.exc(e);
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
void prepareGraphics(Graphics g0, float fract) {
|
||||
Graphics2D g = (Graphics2D)g0;
|
||||
if(fract == 0) {
|
||||
if(rot != 0)
|
||||
g.rotate(rot, x+w/2, y+h/2);
|
||||
return;
|
||||
}
|
||||
if(!(interpTo instanceof RotatedSceneFlob)) return; // XXX?
|
||||
double nrot = rot + fract*(((RotatedSceneFlob)interpTo).rot - rot);
|
||||
if(nrot == 0) return;
|
||||
g.rotate(nrot,
|
||||
(int)((x+w/2)*(1-fract) +
|
||||
fract * (interpTo.x + interpTo.w/2)),
|
||||
(int)((y+h/2)*(1-fract) +
|
||||
fract * (interpTo.y + interpTo.h/2))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
154
Java/arch/javadoc/ZobDoc.java
Normal file
154
Java/arch/javadoc/ZobDoc.java
Normal file
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
ZobDoc.java
|
||||
*
|
||||
* Copyright (c) 2000, Ted Nelson and Tuomas Lukka
|
||||
*
|
||||
* You may use and distribute under the terms of either the GNU Lesser
|
||||
* General Public License, either version 2 of the license or,
|
||||
* at your choice, any later version. Alternatively, you may use and
|
||||
* distribute under the terms of the XPL.
|
||||
*
|
||||
* See the LICENSE.lgpl and LICENSE.xpl files for the specific terms of
|
||||
* the licenses.
|
||||
*
|
||||
* This software 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 README
|
||||
* file for more details.
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Written by Tuomas Lukka
|
||||
*/
|
||||
package org.gzigzag;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
import com.sun.javadoc.*;
|
||||
|
||||
/** A javadoc doclet for extracting ZOb documentation.
|
||||
* Note that compiling and running this file requires the <b>tools.jar</b> file
|
||||
* from JDK 1.3.
|
||||
*/
|
||||
|
||||
public class ZobDoc extends Doclet {
|
||||
public static final String rcsid = "$Id: ZobDoc.java,v 1.2 2000/11/05 18:22:54 tjl Exp $";
|
||||
|
||||
static String[][] lists = new String[][] {
|
||||
{ "org.gzigzag.FlobRaster", "Views", "views.html" },
|
||||
{ "org.gzigzag.RasterFlobFactory", "CellViews", "cellviews.html" }
|
||||
};
|
||||
|
||||
PrintWriter[] listpws = new PrintWriter[lists.length];
|
||||
|
||||
String outdir = null;
|
||||
|
||||
public static boolean start(RootDoc root) {
|
||||
ZobDoc zd = new ZobDoc();
|
||||
return zd.go(root);
|
||||
}
|
||||
|
||||
public boolean go(RootDoc root) {
|
||||
try {
|
||||
readOptions(root.options());
|
||||
|
||||
for(int i=0; i<lists.length; i++) {
|
||||
listpws[i] = new PrintWriter(new FileWriter(
|
||||
new File(outdir, lists[i][2])));
|
||||
}
|
||||
|
||||
ClassDoc[] classes = root.classes();
|
||||
for(int i=0; i < classes.length; i++) {
|
||||
ClassDoc[] ifaces = classes[i].interfaces();
|
||||
boolean iszob = false;
|
||||
for(int j=0; j<ifaces.length; j++) {
|
||||
if(ifaces[j].qualifiedName().equals("org.gzigzag.ZOb"))
|
||||
iszob = true;
|
||||
}
|
||||
if(!iszob) continue;
|
||||
String qname = classes[i].qualifiedName();
|
||||
String filename = qname+".html";
|
||||
// XXX Modules go wrong. Hmm.. should correct.
|
||||
String zobname = null;
|
||||
if(qname.indexOf("org.gzigzag.module.") == 0)
|
||||
zobname = "."+qname.substring(19);
|
||||
else if(qname.indexOf("org.gzigzag.") == 0)
|
||||
zobname = qname.substring(12);
|
||||
else
|
||||
zobname = qname;
|
||||
|
||||
for(int j=0; j<ifaces.length; j++) {
|
||||
for(int l=0; l<lists.length; l++) {
|
||||
if(ifaces[j].qualifiedName().equals(lists[l][0])) {
|
||||
listpws[l].println(filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Now we have the zob.
|
||||
// System.out.println(classes[i].qualifiedName());
|
||||
|
||||
PrintWriter pr = new PrintWriter(
|
||||
new FileWriter(new File(outdir, filename)));
|
||||
|
||||
printDoc(zobname, pr, classes[i]);
|
||||
|
||||
pr.close();
|
||||
}
|
||||
|
||||
for(int i=0; i<lists.length; i++) {
|
||||
listpws[i].close();
|
||||
}
|
||||
} catch(Exception e) {
|
||||
ZZLogger.exc(e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int optionLength(String opt) {
|
||||
if(opt.equals("-d"))
|
||||
return 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void readOptions(String[][] options) {
|
||||
for (int i = 0; i < options.length; i++) {
|
||||
String[] opt = options[i];
|
||||
if (opt[0].equals("-d")) {
|
||||
outdir = opt[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void printDoc(String zobname, PrintWriter pw, ClassDoc cl) {
|
||||
pw.println("<H1>"+zobname+"</H1>");
|
||||
pw.println("<H2 id=\"descr\">Description</H2>");
|
||||
pw.println(cl.commentText());
|
||||
// System.out.println(cl.commentText());
|
||||
|
||||
pw.println("<H2 id=\"params\">Structural parameters</H2>");
|
||||
FieldDoc[] fields = cl.fields();
|
||||
for(int i=0; i<fields.length; i++)
|
||||
printField(pw, fields[i]);
|
||||
|
||||
pw.flush();
|
||||
}
|
||||
|
||||
public void printField(PrintWriter pw, FieldDoc f) {
|
||||
Tag[] tg = f.tags();
|
||||
boolean str = false;
|
||||
for(int i=0; i<tg.length; i++) {
|
||||
if(tg[i].name().equals("@structparam")) str = true;
|
||||
System.out.println("Tag: "+tg[i].name()+" "+tg[i].kind());
|
||||
}
|
||||
if(!str) {
|
||||
System.out.println("Not structparam "+f.name());
|
||||
return;
|
||||
}
|
||||
pw.println("<H3>"+f.name()+"</H3>");
|
||||
pw.println(f.commentText());
|
||||
}
|
||||
}
|
||||
|
||||
19
Java/arch/syslog/arch.mk
Normal file
19
Java/arch/syslog/arch.mk
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
|
||||
JNI_INCLUDE = /usr/include/kaffe/
|
||||
|
||||
all : arch/syslog/libgzigzag-syslog.so
|
||||
|
||||
%.o : %.c
|
||||
$(CC) $(CFLAGS) -I $(JNI_INCLUDE) -fPIC -c -o $@ $<
|
||||
|
||||
arch/syslog/org_gzigzag_SysLogger.o : arch/syslog/org_gzigzag_SysLogger.c arch/syslog/org_gzigzag_SysLogger.h
|
||||
|
||||
arch/syslog/org_gzigzag_SysLogger.h : org/gzigzag/SysLogger.class
|
||||
javah -jni -d arch/syslog org.gzigzag.SysLogger
|
||||
|
||||
arch/syslog/libgzigzag-syslog.so : arch/syslog/org_gzigzag_SysLogger.o
|
||||
$(CC) -shared -o $@ $^
|
||||
|
||||
clean :
|
||||
rm -f arch/syslog/libgzigzag-syslog.so arch/syslog/org_gzigzag_SysLogger.o arch/syslog/org_gzigzag_SysLogger.h
|
||||
46
Java/arch/syslog/org_gzigzag_SysLogger.c
Normal file
46
Java/arch/syslog/org_gzigzag_SysLogger.c
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
org_gzigzag_SysLogger.c
|
||||
*
|
||||
* You may use and distribute under the terms of either the GNU Lesser
|
||||
* General Public License, either version 2 of the license or,
|
||||
* at your choice, any later version. Alternatively, you may use and
|
||||
* distribute under the terms of the XPL.
|
||||
*
|
||||
* See the LICENSE.lgpl and LICENSE.xpl files for the specific terms of
|
||||
* the licenses.
|
||||
*
|
||||
* This software 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 README
|
||||
* file for more details.
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Written by Antti-Juhani Kaijanaho
|
||||
*/
|
||||
|
||||
#include "org_gzigzag_SysLogger.h"
|
||||
#include <syslog.h>
|
||||
|
||||
/*
|
||||
* Class: org_gzigzag_SysLogger
|
||||
* Method: openlog
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_gzigzag_SysLogger_openlog(JNIEnv * env, jclass class) {
|
||||
openlog("gzigzag", LOG_CONS, LOG_DAEMON);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_gzigzag_SysLogger
|
||||
* Method: syslog
|
||||
* Signature: (Ljava/lang/String;Z)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_gzigzag_SysLogger_syslog(JNIEnv * env, jclass class, jstring msg, jboolean verb) {
|
||||
const char * s;
|
||||
|
||||
jboolean isCopy = JNI_FALSE;
|
||||
s = (*env)->GetStringUTFChars(env, msg, &isCopy);
|
||||
syslog((verb == JNI_TRUE) ? LOG_NOTICE : LOG_INFO, s);
|
||||
(*env)->ReleaseStringUTFChars(env, msg, s);
|
||||
}
|
||||
Reference in New Issue
Block a user