mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-16 14:41:58 +00:00
ttf: get rid of slow xmls
This commit is contained in:
BIN
lib/ttf.jar
BIN
lib/ttf.jar
Binary file not shown.
@@ -36,7 +36,6 @@ import com.jpexs.helpers.Helper;
|
||||
import fontastic.FGlyph;
|
||||
import fontastic.FPoint;
|
||||
import fontastic.Fontastic;
|
||||
import fontastic.PVector;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
@@ -187,19 +186,19 @@ public class FontExporter {
|
||||
@Override
|
||||
public void moveTo(double x, double y) {
|
||||
finalizePath();
|
||||
path.add(new FPoint(new PVector(transformX(x), transformY(y))));
|
||||
path.add(new FPoint(transformX(x), transformY(y)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lineTo(double x, double y) {
|
||||
path.add(new FPoint(new PVector(transformX(x), transformY(y))));
|
||||
path.add(new FPoint(transformX(x), transformY(y)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void curveTo(double controlX, double controlY, double anchorX, double anchorY) {
|
||||
path.add(new FPoint(
|
||||
new PVector(transformX(anchorX), transformY(anchorY)),
|
||||
new PVector(transformX(controlX), transformY(controlY))
|
||||
new FPoint(transformX(anchorX), transformY(anchorY)),
|
||||
new FPoint(transformX(controlX), transformY(controlY))
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
@@ -46,27 +46,20 @@ public class FContour {
|
||||
this.points = new ArrayList<>();
|
||||
}
|
||||
|
||||
FContour(PVector[] points) {
|
||||
FContour(FPoint[] points) {
|
||||
this.points = new ArrayList<>();
|
||||
for (PVector p : points) {
|
||||
this.points.add(new FPoint(p));
|
||||
for (FPoint p : points) {
|
||||
this.points.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
FContour(PVector[] points, PVector[] controlpoints) {
|
||||
FContour(FPoint[] points, FPoint[] controlpoints) {
|
||||
this.points = new ArrayList<>();
|
||||
for (int i=0; i<points.length; i++) {
|
||||
this.points.add(new FPoint(points[i], controlpoints[i] ));
|
||||
}
|
||||
}
|
||||
|
||||
FContour(FPoint[] points) {
|
||||
this.points = new ArrayList<>();
|
||||
for (int i=0; i<points.length; i++) {
|
||||
this.points.add(points[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public List<FPoint> getPoints() {
|
||||
return points;
|
||||
}
|
||||
@@ -76,10 +69,10 @@ public class FContour {
|
||||
return pointsArray;
|
||||
}
|
||||
|
||||
public void setPoints(PVector[] points) {
|
||||
public void setPoints(FPoint[] points) {
|
||||
this.points = new ArrayList<>();
|
||||
for (PVector p : points) {
|
||||
this.points.add(new FPoint(p));
|
||||
for (FPoint p : points) {
|
||||
this.points.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,15 +52,11 @@ public class FGlyph {
|
||||
contours.add(new FContour());
|
||||
}
|
||||
|
||||
public void addContour(PVector[] points) {
|
||||
contours.add(new FContour(points));
|
||||
}
|
||||
|
||||
public void addContour(FPoint[] points) {
|
||||
contours.add(new FContour(points));
|
||||
}
|
||||
|
||||
public void addContour(PVector[] points, PVector[] controlPoints) {
|
||||
public void addContour(FPoint[] points, FPoint[] controlPoints) {
|
||||
contours.add(new FContour(points, controlPoints));
|
||||
}
|
||||
|
||||
@@ -97,10 +93,6 @@ public class FGlyph {
|
||||
return contours.size();
|
||||
}
|
||||
|
||||
public void setContour(int index, PVector[] points) {
|
||||
contours.set(index, new FContour(points));
|
||||
}
|
||||
|
||||
public void setContour(int index, FPoint[] points) {
|
||||
contours.set(index, new FContour(points));
|
||||
}
|
||||
|
||||
@@ -35,42 +35,45 @@ package fontastic;
|
||||
* Stores a point with x and y coordinates and optional PVector controlPoint1 and controlPoint2.
|
||||
*
|
||||
*/
|
||||
public class FPoint extends PVector {
|
||||
public class FPoint {
|
||||
|
||||
public PVector controlPoint;
|
||||
public double x;
|
||||
public double y;
|
||||
|
||||
public FPoint controlPoint;
|
||||
|
||||
private boolean hasControlPoint;
|
||||
|
||||
public FPoint() {
|
||||
}
|
||||
|
||||
public FPoint(PVector point) {
|
||||
public FPoint(FPoint point) {
|
||||
this.x = point.x;
|
||||
this.y = point.y;
|
||||
this.hasControlPoint = false;
|
||||
}
|
||||
|
||||
public FPoint(float x, float y) {
|
||||
public FPoint(double x, double y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.hasControlPoint = false;
|
||||
}
|
||||
|
||||
|
||||
public FPoint(PVector point, PVector controlPoint) {
|
||||
public FPoint(FPoint point, FPoint controlPoint) {
|
||||
this.x = point.x;
|
||||
this.y = point.y;
|
||||
this.controlPoint = controlPoint;
|
||||
this.hasControlPoint = true;
|
||||
}
|
||||
|
||||
public void setControlPoint(PVector controlPoint1) {
|
||||
public void setControlPoint(FPoint controlPoint1) {
|
||||
this.controlPoint = controlPoint1;
|
||||
this.hasControlPoint = true;
|
||||
}
|
||||
|
||||
public void setControlPoint(float x, float y) {
|
||||
this.controlPoint = new PVector(x,y);
|
||||
this.controlPoint = new FPoint(x, y);
|
||||
this.hasControlPoint = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,11 +32,7 @@ import org.doubletype.ossa.adapter.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
/**
|
||||
* Fontastic A font file writer to create TTF and WOFF (Webfonts).
|
||||
@@ -45,55 +41,30 @@ import java.util.regex.Matcher;
|
||||
*/
|
||||
public class Fontastic {
|
||||
|
||||
private org.doubletype.ossa.module.TypefaceFile typeface;
|
||||
private org.doubletype.ossa.Engine m_engine;
|
||||
|
||||
private String fontname;
|
||||
private String fontName;
|
||||
|
||||
private List<FGlyph> glyphs;
|
||||
|
||||
private int advanceWidth = 512;
|
||||
|
||||
private File ttffile;
|
||||
private File outfile;
|
||||
private File ttfFile;
|
||||
private File outFile;
|
||||
private File tempDir;
|
||||
|
||||
public final static String VERSION = "0.4";
|
||||
|
||||
/**
|
||||
* Uppercase alphabet 26 characters *
|
||||
*/
|
||||
public final static char alphabet[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
||||
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
|
||||
'U', 'V', 'W', 'X', 'Y', 'Z'};
|
||||
/**
|
||||
* Lowercase alphabet 26 characters *
|
||||
*/
|
||||
public final static char alphabetLc[] = {'a', 'b', 'c', 'd', 'e', 'f',
|
||||
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
|
||||
't', 'u', 'v', 'w', 'x', 'y', 'z'};
|
||||
|
||||
/**
|
||||
* Return the version of the library.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public static String version() {
|
||||
return VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @example Fontastic f = new Fontastic(this, "MyFont");
|
||||
*
|
||||
* @param theParent Your processing sketch (this).
|
||||
* @param fontname Font name
|
||||
* @param fontName Font name
|
||||
* @param outFile
|
||||
*
|
||||
*/
|
||||
public Fontastic(String fontname, File outfile) throws IOException {
|
||||
this.fontname = fontname;
|
||||
this.outfile = outfile;
|
||||
public Fontastic(String fontName, File outFile) throws IOException {
|
||||
this.fontName = fontName;
|
||||
this.outFile = outFile;
|
||||
intitialiseFont();
|
||||
this.glyphs = new ArrayList<>();
|
||||
}
|
||||
@@ -104,7 +75,7 @@ public class Fontastic {
|
||||
* @return String
|
||||
*/
|
||||
public String getFontname() {
|
||||
return fontname;
|
||||
return fontName;
|
||||
}
|
||||
|
||||
private static File createTempDirectory()
|
||||
@@ -132,27 +103,17 @@ public class Fontastic {
|
||||
private void intitialiseFont() throws IOException {
|
||||
|
||||
tempDir = createTempDirectory();
|
||||
/*if (!tempDir.exists()) {
|
||||
if(!tempDir.mkdirs()){
|
||||
if (!tempDir.exists()) {
|
||||
throw new IOException("Cannot create temp dir");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//deleteFolderContents(tempDir, false);
|
||||
}*/
|
||||
|
||||
|
||||
m_engine = Engine.getSingletonInstance();
|
||||
m_engine.buildNewTypeface(fontname, tempDir);
|
||||
m_engine = new Engine();
|
||||
m_engine.buildNewTypeface(fontName, tempDir);
|
||||
|
||||
this.setFontFamilyName(fontname);
|
||||
this.setFontFamilyName(fontName);
|
||||
this.setVersion("CC BY-SA 3.0 http://creativecommons.org/licenses/by-sa/3.0/"); // default
|
||||
// license
|
||||
|
||||
String directoryName = tempDir + File.separator + "bin" + File.separator;
|
||||
String directoryName = tempDir + File.separator;
|
||||
|
||||
ttffile = new File(directoryName + fontname + ".ttf");
|
||||
ttfFile = new File(directoryName + fontName + ".ttf");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,12 +121,11 @@ public class Fontastic {
|
||||
* template for previewing the WOFF. If debug is set (default is true) then
|
||||
* you'll see the .ttf and .woff file name in the console.
|
||||
*/
|
||||
public void buildFont() throws FileNotFoundException {
|
||||
public void buildFont() {
|
||||
// Create TTF file with doubletype
|
||||
//m_engine.fireAction();
|
||||
//m_engine.addDefaultGlyphs();
|
||||
|
||||
List<GlyphFile> glyphFiles = new ArrayList<>(glyphs.size());
|
||||
for (FGlyph glyph : glyphs) {
|
||||
|
||||
m_engine.checkUnicodeBlock(glyph.getGlyphChar());
|
||||
@@ -200,18 +160,16 @@ public class Fontastic {
|
||||
|
||||
glyphFile.addContour(econtour);
|
||||
}
|
||||
|
||||
glyphFiles.add(glyphFile);
|
||||
}
|
||||
|
||||
m_engine.getTypeface().addRequiredGlyphs();
|
||||
m_engine.buildTrueType(false);
|
||||
m_engine.buildTrueType();
|
||||
|
||||
// End TTF creation
|
||||
if(outfile.exists()){
|
||||
outfile.delete();
|
||||
if(outFile.exists()){
|
||||
outFile.delete();
|
||||
}
|
||||
ttffile.renameTo(outfile);
|
||||
ttfFile.renameTo(outFile);
|
||||
cleanup();
|
||||
}
|
||||
|
||||
@@ -229,14 +187,14 @@ public class Fontastic {
|
||||
/**
|
||||
* Sets the author of the font.
|
||||
*/
|
||||
public void setAuthor(String author) throws FileNotFoundException {
|
||||
public void setAuthor(String author) {
|
||||
m_engine.setAuthor(author);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the copyright year of the font.
|
||||
*/
|
||||
public void setCopyrightYear(String copyrightYear) throws FileNotFoundException {
|
||||
public void setCopyrightYear(String copyrightYear) {
|
||||
m_engine.setCopyrightYear(copyrightYear);
|
||||
}
|
||||
|
||||
@@ -244,7 +202,7 @@ public class Fontastic {
|
||||
* Sets the version of the font (default is "0.1").
|
||||
*/
|
||||
public void setVersion(String version) {
|
||||
m_engine.getTypeface().getGlyph().getHead().setVersion(version);
|
||||
m_engine.getTypeface().setVersion(version);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -252,14 +210,14 @@ public class Fontastic {
|
||||
* changed with setFontFamilyName() it won't affect folder the font is
|
||||
* stored in.
|
||||
*/
|
||||
public void setFontFamilyName(String fontFamilyName) throws FileNotFoundException {
|
||||
public void setFontFamilyName(String fontFamilyName) {
|
||||
m_engine.setFontFamilyName(fontFamilyName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the sub family of the font.
|
||||
*/
|
||||
public void setSubFamily(String subFamily) throws FileNotFoundException {
|
||||
public void setSubFamily(String subFamily) {
|
||||
m_engine.getTypeface().setSubFamily(subFamily);
|
||||
}
|
||||
|
||||
@@ -267,21 +225,21 @@ public class Fontastic {
|
||||
* Sets the license of the font (default is "CC BY-SA 3.0
|
||||
* http://creativecommons.org/licenses/by-sa/3.0/")
|
||||
*/
|
||||
public void setTypefaceLicense(String typefaceLicense) throws FileNotFoundException {
|
||||
public void setTypefaceLicense(String typefaceLicense) {
|
||||
m_engine.setTypefaceLicense(typefaceLicense);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the baseline of the font.
|
||||
*/
|
||||
public void setBaseline(float baseline) throws FileNotFoundException {
|
||||
public void setBaseline(float baseline) {
|
||||
m_engine.setBaseline(baseline);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the meanline of the font.
|
||||
*/
|
||||
public void setMeanline(float meanline) throws FileNotFoundException {
|
||||
public void setMeanline(float meanline) {
|
||||
m_engine.setMeanline(meanline);
|
||||
}
|
||||
|
||||
@@ -294,7 +252,7 @@ public class Fontastic {
|
||||
this.advanceWidth = advanceWidth;
|
||||
}
|
||||
|
||||
public void setTopSideBearing(float topSideBearing) throws FileNotFoundException {
|
||||
public void setTopSideBearing(float topSideBearing) {
|
||||
try {
|
||||
m_engine.getTypeface().setTopSideBearing(topSideBearing);
|
||||
} catch (OutOfRangeException e) {
|
||||
@@ -305,7 +263,7 @@ public class Fontastic {
|
||||
}
|
||||
}
|
||||
|
||||
public void setBottomSideBearing(float bottomSideBearing) throws FileNotFoundException {
|
||||
public void setBottomSideBearing(float bottomSideBearing) {
|
||||
try {
|
||||
m_engine.getTypeface().setBottomSideBearing(bottomSideBearing);
|
||||
} catch (OutOfRangeException e) {
|
||||
@@ -316,7 +274,7 @@ public class Fontastic {
|
||||
}
|
||||
}
|
||||
|
||||
public void setAscender(float ascender) throws FileNotFoundException {
|
||||
public void setAscender(float ascender) {
|
||||
try {
|
||||
m_engine.getTypeface().setAscender(ascender);
|
||||
} catch (OutOfRangeException e) {
|
||||
@@ -327,7 +285,7 @@ public class Fontastic {
|
||||
}
|
||||
}
|
||||
|
||||
public void setDescender(float descender) throws FileNotFoundException {
|
||||
public void setDescender(float descender) {
|
||||
try {
|
||||
m_engine.getTypeface().setDescender(descender);
|
||||
} catch (OutOfRangeException e) {
|
||||
@@ -338,7 +296,7 @@ public class Fontastic {
|
||||
}
|
||||
}
|
||||
|
||||
public void setXHeight(float xHeight) throws FileNotFoundException {
|
||||
public void setXHeight(float xHeight) {
|
||||
try {
|
||||
m_engine.getTypeface().setXHeight(xHeight);
|
||||
} catch (OutOfRangeException e) {
|
||||
@@ -357,7 +315,7 @@ public class Fontastic {
|
||||
* // 2 px setBottomSideBearing(0); // 0px
|
||||
*
|
||||
*/
|
||||
public void setDefaultMetrics() throws FileNotFoundException {
|
||||
public void setDefaultMetrics() {
|
||||
m_engine.getTypeface().setDefaultMetrics();
|
||||
}
|
||||
|
||||
@@ -383,7 +341,7 @@ public class Fontastic {
|
||||
*
|
||||
* @param c Character of the glyph.
|
||||
*
|
||||
* @param FContour Shape of the glyph as FContour.
|
||||
* @param contour Shape of the glyph as FContour.
|
||||
*
|
||||
* @return The glyph FGlyph that has been created. You can use this to store
|
||||
* the glyph and add contours afterwards. Alternatively, you can call
|
||||
@@ -405,7 +363,7 @@ public class Fontastic {
|
||||
*
|
||||
* @param c Character of the glyph.
|
||||
*
|
||||
* @param FContour [] Shape of the glyph in an array of FContour.
|
||||
* @param contours Shape of the glyph in an array of FContour.
|
||||
*
|
||||
* @return The FGlyph that has been created. You can use this to store the
|
||||
* glyph and add contours afterwards. Alternatively, you can call
|
||||
@@ -417,7 +375,6 @@ public class Fontastic {
|
||||
glyphs.add(glyph);
|
||||
|
||||
for (FContour contour : contours) {
|
||||
// if (debug) System.out.println(p.x + " - " + p.y);
|
||||
glyph.addContour(contour);
|
||||
}
|
||||
glyph.setAdvanceWidth(advanceWidth);
|
||||
@@ -471,7 +428,7 @@ public class Fontastic {
|
||||
* @return The .ttf file name, which is being created when you call build()
|
||||
*/
|
||||
public String getTTFfilename() {
|
||||
return ttffile.toString();
|
||||
return ttfFile.toString();
|
||||
}
|
||||
|
||||
private static void deleteFolderContents(File folder,
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package fontastic;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class PVector {
|
||||
public double x;
|
||||
public double y;
|
||||
|
||||
public PVector() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public PVector(double x, double y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,31 +1,30 @@
|
||||
package fontatest;
|
||||
|
||||
import fontastic.FPoint;
|
||||
import fontastic.Fontastic;
|
||||
import fontastic.PVector;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
public class FontaTest {
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args) throws IOException {
|
||||
File file=new File("example.ttf");
|
||||
file.delete();
|
||||
Fontastic f = new Fontastic("ExampleFont",file);
|
||||
f.setAuthor("Nobody");
|
||||
FPoint[] points = new FPoint[]{ // Define a PVector array containing the points of the shape
|
||||
new FPoint(0, 0),
|
||||
new FPoint(512,0),
|
||||
//new FPoint(256, 1024),
|
||||
new FPoint(new PVector(256,1024), new PVector(512,512)),
|
||||
new FPoint(0, 0)
|
||||
};
|
||||
f.addGlyph('P').addContour(points); // Assign contour to character A
|
||||
f.buildFont();
|
||||
}
|
||||
|
||||
}
|
||||
package fontatest;
|
||||
|
||||
import fontastic.FPoint;
|
||||
import fontastic.Fontastic;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
public class FontaTest {
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args) throws IOException {
|
||||
File file=new File("example.ttf");
|
||||
file.delete();
|
||||
Fontastic f = new Fontastic("ExampleFont",file);
|
||||
f.setAuthor("Nobody");
|
||||
FPoint[] points = new FPoint[]{ // Define a FPoint array containing the points of the shape
|
||||
new FPoint(0, 0),
|
||||
new FPoint(512,0),
|
||||
//new FPoint(256, 1024),
|
||||
new FPoint(new FPoint(256,1024), new FPoint(512,512)),
|
||||
new FPoint(0, 0)
|
||||
};
|
||||
f.addGlyph('P').addContour(points); // Assign contour to character A
|
||||
f.buildFont();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,199 +0,0 @@
|
||||
/*
|
||||
* $Id: ActiveList.java,v 1.7 2004/11/15 03:39:38 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.doubletype.ossa.adapter.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class ActiveList {
|
||||
private static ActiveList s_actives = null;
|
||||
|
||||
public static ActiveList getSingletonInstance() {
|
||||
if (s_actives == null)
|
||||
s_actives = new ActiveList();
|
||||
|
||||
return s_actives;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
public ArrayList<GlyphObject> m_activeObjects = new ArrayList<>();
|
||||
|
||||
public void unselectAll() {
|
||||
m_activeObjects.clear();
|
||||
}
|
||||
|
||||
public boolean hasSelected() {
|
||||
return size() > 0;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return m_activeObjects.size();
|
||||
}
|
||||
|
||||
public GlyphObject get(int a_index) {
|
||||
return m_activeObjects.get(a_index);
|
||||
}
|
||||
|
||||
public boolean isSelected(Object a_value) {
|
||||
int i;
|
||||
|
||||
// use equal method to compare this will catch XContour etc...
|
||||
for (i = 0; i < size(); i++) {
|
||||
if (get(i) == a_value) {
|
||||
return true;
|
||||
} // if
|
||||
} // for i
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void addActive(GlyphObject a_object) {
|
||||
if (isSelected(a_object)) {
|
||||
return;
|
||||
} // if
|
||||
|
||||
m_activeObjects.add(a_object);
|
||||
}
|
||||
|
||||
public void setActives(ActiveList a_actives) {
|
||||
unselectAll();
|
||||
|
||||
int i;
|
||||
for (i = 0; i < a_actives.size(); i++) {
|
||||
addActive(a_actives.get(i));
|
||||
} // for i
|
||||
}
|
||||
|
||||
private GlyphObject getTheActive() {
|
||||
GlyphObject retval = null;
|
||||
|
||||
if (m_activeObjects.size() == 1) {
|
||||
retval = get(0);
|
||||
} // if
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
public boolean hasActiveModule() {
|
||||
return (getTheActive() instanceof EModuleInvoke);
|
||||
}
|
||||
|
||||
public EModuleInvoke getActiveModule() {
|
||||
if (hasActiveModule()) {
|
||||
return (EModuleInvoke) getTheActive();
|
||||
} else {
|
||||
return null;
|
||||
} // if-else
|
||||
}
|
||||
|
||||
public boolean hasActiveContour() {
|
||||
return (getTheActive() instanceof EContour);
|
||||
}
|
||||
|
||||
public EContour getActiveContour() {
|
||||
if (getTheActive() instanceof EContour) {
|
||||
return (EContour) getTheActive();
|
||||
} else {
|
||||
return null;
|
||||
} // if-else
|
||||
}
|
||||
|
||||
public boolean hasActiveInclude() {
|
||||
return (getTheActive() instanceof EIncludeInvoke);
|
||||
}
|
||||
|
||||
public EIncludeInvoke getActiveInclude() {
|
||||
if (hasActiveInclude()) {
|
||||
return (EIncludeInvoke) getTheActive();
|
||||
} // if
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasActiveControlPoint() {
|
||||
return (getTheActive() instanceof EControlPoint);
|
||||
}
|
||||
|
||||
public EControlPoint getActiveControlPoint() {
|
||||
if (hasActiveControlPoint()) {
|
||||
return (EControlPoint) getTheActive();
|
||||
} // if
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasActivePoint() {
|
||||
return (getTheActive() instanceof EContourPoint);
|
||||
}
|
||||
|
||||
public EContourPoint getActivePoint() {
|
||||
if (hasActivePoint()) {
|
||||
return (EContourPoint) getTheActive();
|
||||
} else {
|
||||
return null;
|
||||
} // if
|
||||
}
|
||||
|
||||
public boolean hasActiveHint() {
|
||||
return (getTheActive() instanceof EHint);
|
||||
}
|
||||
|
||||
public String getSelectedAsString() {
|
||||
String retval = "";
|
||||
|
||||
if (!hasSelected()) {
|
||||
return retval;
|
||||
} // if
|
||||
|
||||
retval = "<clipboard>";
|
||||
|
||||
int i;
|
||||
for (i = 0; i < size(); i++) {
|
||||
GlyphObject active = get(i);
|
||||
retval += active.toString();
|
||||
} // for i
|
||||
|
||||
retval += "</clipboard>";
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
*/
|
||||
package org.doubletype.ossa;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class AppSettings extends Object {
|
||||
private static String k_lastTypefaceFile = "lastTypefaceFile";
|
||||
|
||||
private static File s_fileName = new File("./.properties");
|
||||
private static Properties s_properties;
|
||||
|
||||
public static String getLastTypefaceDir() {
|
||||
loadPropertyFile();
|
||||
return s_properties.getProperty(k_lastTypefaceFile, "./");
|
||||
}
|
||||
|
||||
public static void setLastTypefaceDir(String a_value) {
|
||||
loadPropertyFile();
|
||||
s_properties.setProperty(k_lastTypefaceFile, a_value);
|
||||
savePropertyFile();
|
||||
}
|
||||
|
||||
private static void loadPropertyFile() {
|
||||
if (s_properties != null) {
|
||||
return;
|
||||
} // if
|
||||
|
||||
s_properties = new Properties();
|
||||
if (s_fileName.exists()) {
|
||||
try {
|
||||
s_properties.load(new FileInputStream(s_fileName));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} // try-catch
|
||||
} // if
|
||||
}
|
||||
|
||||
private static void savePropertyFile() {
|
||||
if (s_properties == null) {
|
||||
return;
|
||||
} // if
|
||||
|
||||
try {
|
||||
s_properties.store(new FileOutputStream(s_fileName),
|
||||
"DoubleType AppSetting File");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} // try-catch
|
||||
}
|
||||
}
|
||||
@@ -35,23 +35,13 @@
|
||||
|
||||
package org.doubletype.ossa;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.geom.*;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.TreeSelectionListener;
|
||||
import javax.swing.tree.*;
|
||||
import javax.swing.event.*;
|
||||
|
||||
import org.doubletype.ossa.adapter.*;
|
||||
import org.doubletype.ossa.module.*;
|
||||
import org.doubletype.ossa.truetype.*;
|
||||
|
||||
@@ -59,252 +49,14 @@ import org.doubletype.ossa.truetype.*;
|
||||
* @author e.e
|
||||
*/
|
||||
public class Engine {
|
||||
// --------------------------------------------------------------
|
||||
|
||||
// used by findFile
|
||||
public static final int USER_CANCELLED = -1;
|
||||
public static final int FILE_NOT_FOUND = 0;
|
||||
public static final int FILE_FOUND = 1;
|
||||
|
||||
// used by Find
|
||||
public static final int SEARCH_BY_EXAMPLE = 0;
|
||||
public static final int SEARCH_UNICODE = 1;
|
||||
public static final int SEARCH_JIS_CODE = 2;
|
||||
|
||||
// public static final double k_fontSizes [] = {9, 10, 11, 12, 14, 18, 24, 36, 72};
|
||||
public static final int k_defaultPixelSize = 16;
|
||||
public static final int k_resolutions [] = {96, 72, 75, 100};
|
||||
public static final int k_defaultResolution = 96;
|
||||
public static final int k_zooms [] = {25, 50, 100};
|
||||
public static final int k_defaultZoom = 100;
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
private static int s_em = 1024;
|
||||
private static Engine s_singleton = null;
|
||||
|
||||
public static Engine getSingletonInstance() {
|
||||
if (s_singleton == null)
|
||||
s_singleton = new Engine();
|
||||
return s_singleton;
|
||||
}
|
||||
|
||||
public static int getEm() {
|
||||
return TTPixelSize.getEm();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
private UiBridge m_ui;
|
||||
|
||||
private TypefaceFile m_typeface;
|
||||
private GlyphFile m_root;
|
||||
private ActiveList m_actives;
|
||||
private ArrayList<ActionListener> m_listeners = new ArrayList<>();
|
||||
|
||||
private String m_foundFileName;
|
||||
private Clipboard m_clipboard;
|
||||
private JFileChooser m_gifChooser;
|
||||
private JFileChooser m_chooser;
|
||||
|
||||
private Action m_deleteAction;
|
||||
private Action m_addPointAction;
|
||||
private Action m_toggleAction;
|
||||
private Action m_hintAction;
|
||||
private Action m_contourAction;
|
||||
private Action m_moduleAction;
|
||||
private Action m_includeAction;
|
||||
private Action m_selectNextAction;
|
||||
private Action m_roundAction;
|
||||
private Action m_propertyAction;
|
||||
private Action m_convertControlPointAction;
|
||||
private Action m_convertContourAction;
|
||||
|
||||
private String m_msgAlreadyExists = " already exists!";
|
||||
private String m_msgNoTypeface = "no typeface";
|
||||
private String m_msgEmptyGlyphTitle = "glyph title is empty";
|
||||
private String m_msgGlyphName = "glyph name?";
|
||||
private String m_msgCircular = "circular include!";
|
||||
private String m_msgNoJis = "Charset ISO-2022-JP is not supported.\n"
|
||||
+ "Please include charsets.jar in classpath.";
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
private Engine() {
|
||||
//GlyphFactory.setFactory(new EGlyphFactory());
|
||||
|
||||
|
||||
|
||||
m_typeface = null;
|
||||
m_root = null;
|
||||
|
||||
m_clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
m_actives = ActiveList.getSingletonInstance();
|
||||
|
||||
initActions();
|
||||
public Engine() {
|
||||
}
|
||||
|
||||
private void initActions() {
|
||||
|
||||
}
|
||||
|
||||
public Action [] buildCommands() {
|
||||
ArrayList actions = buildCommandsArrayList();
|
||||
Action [] retval = new Action[actions.size()];
|
||||
int i;
|
||||
for (i = 0; i < actions.size(); i++) {
|
||||
retval[i] = (Action) actions.get(i);
|
||||
} // for i
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
private ArrayList buildCommandsArrayList() {
|
||||
ArrayList<Action> retval = new ArrayList<>();
|
||||
|
||||
if (m_root == null) {
|
||||
return retval;
|
||||
} // if
|
||||
|
||||
if (m_actives.hasActiveContour()) {
|
||||
retval.add(m_convertContourAction);
|
||||
}
|
||||
|
||||
if (m_actives.hasActiveControlPoint()) {
|
||||
EControlPoint controlPoint = m_actives.getActiveControlPoint();
|
||||
retval.add(m_convertControlPointAction);
|
||||
}
|
||||
|
||||
if (m_actives.hasActivePoint()) {
|
||||
EContourPoint point = m_actives.getActivePoint();
|
||||
|
||||
retval.add(m_toggleAction);
|
||||
|
||||
if (!point.isRounded()) {
|
||||
retval.add(m_hintAction);
|
||||
} // if
|
||||
|
||||
if (!point.hasHintForCurrentPpem()) {
|
||||
retval.add(m_roundAction);
|
||||
} // if
|
||||
} // if
|
||||
|
||||
if (m_actives.size() > 0) {
|
||||
// retval.add(m_propertyAction);
|
||||
retval.add(m_deleteAction);
|
||||
} // if
|
||||
|
||||
if (m_actives.hasActivePoint()) {
|
||||
retval.add(m_addPointAction);
|
||||
} // if
|
||||
|
||||
/*if (!GlyphAction.isPointVisible()) {
|
||||
retval.add(m_moduleAction);
|
||||
retval.add(m_contourAction);
|
||||
retval.add(m_includeAction);
|
||||
} // if*/
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
public void localize(ResourceBundle a_bundle) {
|
||||
m_msgAlreadyExists = a_bundle.getString("msgAlreadyExists");
|
||||
m_msgNoTypeface = a_bundle.getString("msgNoTypeface");
|
||||
m_msgEmptyGlyphTitle = a_bundle.getString("msgEmptyGlyphTitle");
|
||||
m_msgGlyphName = a_bundle.getString("msgGlyphName");
|
||||
m_msgCircular = a_bundle.getString("msgCircular");
|
||||
}
|
||||
|
||||
private void showPropertyDialog() {
|
||||
if (m_actives.size() != 1) {
|
||||
return;
|
||||
} // if
|
||||
|
||||
m_ui.showPropertyDialog(m_actives.get(0));
|
||||
}
|
||||
|
||||
public void setUi(UiBridge a_ui) {
|
||||
m_ui = a_ui;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void selectNext() {
|
||||
if (m_root == null) {
|
||||
return;
|
||||
} // if
|
||||
|
||||
m_root.selectNext();
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
if (m_root == null)
|
||||
return;
|
||||
if (!m_actives.hasSelected()) {
|
||||
return;
|
||||
} // if
|
||||
|
||||
m_root.remove();
|
||||
}
|
||||
|
||||
public void cutToClipboard() {
|
||||
if (m_root == null)
|
||||
return;
|
||||
if (!m_actives.hasSelected()) {
|
||||
return;
|
||||
} // if
|
||||
|
||||
copyToClipboard();
|
||||
delete();
|
||||
}
|
||||
|
||||
public void copyToClipboard() {
|
||||
if (m_root == null)
|
||||
return;
|
||||
if (!m_actives.hasSelected()) {
|
||||
return;
|
||||
} // if
|
||||
|
||||
String s = m_actives.getSelectedAsString();
|
||||
if (s.equals("")) {
|
||||
return;
|
||||
} // if
|
||||
|
||||
StringSelection selection = new StringSelection(s);
|
||||
|
||||
try {
|
||||
m_clipboard.setContents(selection, selection);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} // try-catch
|
||||
}
|
||||
|
||||
public void pasteFromClipboard() {
|
||||
if (m_root == null)
|
||||
return;
|
||||
Transferable content = null;
|
||||
String s = "";
|
||||
|
||||
try {
|
||||
content = m_clipboard.getContents(this);
|
||||
if (content == null)
|
||||
return;
|
||||
s = (String) content.getTransferData(DataFlavor.stringFlavor);
|
||||
if (s.equals("")) {
|
||||
return;
|
||||
} // if
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
} // try-catch
|
||||
|
||||
try {
|
||||
m_root.addObjectFromClipboard(s);
|
||||
} catch (GlyphFile.CircularIncludeException e) {
|
||||
Logger.getLogger(Engine.class.getName()).log(Level.SEVERE, m_msgCircular, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void setAdvanceWidth(int a_value) {
|
||||
if (m_root == null)
|
||||
return;
|
||||
@@ -312,34 +64,10 @@ public class Engine {
|
||||
m_root.setAdvanceWidth(a_value);
|
||||
}
|
||||
|
||||
public void moveLeft() {
|
||||
move(new Point2D.Double(-1, 0));
|
||||
}
|
||||
|
||||
public void moveUp() {
|
||||
move(new Point2D.Double(0, 1));
|
||||
}
|
||||
|
||||
public void moveDown() {
|
||||
move(new Point2D.Double(0, -1));
|
||||
}
|
||||
|
||||
public void moveRight() {
|
||||
move(new Point2D.Double(1, 0));
|
||||
}
|
||||
|
||||
private void move(Point2D a_delta) {
|
||||
if (m_root == null) {
|
||||
return;
|
||||
} // if
|
||||
|
||||
m_root.move(a_delta);
|
||||
}
|
||||
|
||||
public void buildNewTypeface(String a_name, File a_dir) throws FileNotFoundException {
|
||||
if (a_name == null || a_name.equals("")) {
|
||||
return;
|
||||
} // if
|
||||
}
|
||||
|
||||
TypefaceFile typeface = new TypefaceFile(a_name, a_dir);
|
||||
typeface.setAuthor("no body");
|
||||
@@ -353,68 +81,20 @@ public class Engine {
|
||||
setTypeface(typeface);
|
||||
}
|
||||
|
||||
public void addDefaultGlyphs() throws FileNotFoundException {
|
||||
public void addDefaultGlyphs() {
|
||||
m_typeface.addRequiredGlyphs();
|
||||
m_typeface.addBasicLatinGlyphs();
|
||||
}
|
||||
|
||||
public void openTypeface() throws FileNotFoundException {
|
||||
if (m_chooser == null) {
|
||||
m_chooser = new JFileChooser(new File(AppSettings.getLastTypefaceDir()));
|
||||
} // if
|
||||
|
||||
m_chooser.setFileFilter(new TypefaceFileFilter());
|
||||
int returnVal = m_chooser.showOpenDialog(null);
|
||||
|
||||
if (returnVal != JFileChooser.APPROVE_OPTION) {
|
||||
return;
|
||||
} // if
|
||||
|
||||
AppSettings.setLastTypefaceDir(m_chooser.getSelectedFile().toString());
|
||||
openTypeface(m_chooser.getSelectedFile());
|
||||
}
|
||||
|
||||
private void openTypeface(File a_file) throws FileNotFoundException {
|
||||
setTypeface(new TypefaceFile(a_file));
|
||||
|
||||
if (m_typeface.addRequiredGlyphs()) {
|
||||
} // if
|
||||
}
|
||||
|
||||
public void setTypeface(TypefaceFile a_typeface) {
|
||||
m_typeface = a_typeface;
|
||||
}
|
||||
|
||||
public void changeUnicode(long a_unicode) throws FileNotFoundException {
|
||||
if (m_typeface == null || m_root == null) {
|
||||
return;
|
||||
} // if
|
||||
|
||||
m_typeface.setGlyphUnicode(m_root, a_unicode);
|
||||
}
|
||||
|
||||
public int findFile(long a_unicode) {
|
||||
if (m_typeface == null)
|
||||
return USER_CANCELLED;
|
||||
|
||||
m_foundFileName = m_typeface.unicodeToFileName(a_unicode);
|
||||
if (m_foundFileName != null) {
|
||||
return FILE_FOUND;
|
||||
} // if
|
||||
|
||||
return FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
public String getFoundFileName() {
|
||||
return m_foundFileName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create glyph out of given unicode, and add it to the typeface.
|
||||
* @param a_unicode
|
||||
*/
|
||||
public GlyphFile addNewGlyph(long a_unicode) throws FileNotFoundException {
|
||||
public GlyphFile addNewGlyph(long a_unicode) {
|
||||
GlyphFile retval;
|
||||
|
||||
retval = m_typeface.createGlyph(a_unicode);
|
||||
@@ -423,7 +103,7 @@ public class Engine {
|
||||
return retval;
|
||||
}
|
||||
|
||||
public void checkUnicodeBlock(long a_unicode) throws FileNotFoundException {
|
||||
public void checkUnicodeBlock(long a_unicode) {
|
||||
TTUnicodeRange range = TTUnicodeRange.of(a_unicode);
|
||||
if (range == null){
|
||||
return;
|
||||
@@ -435,53 +115,26 @@ public class Engine {
|
||||
m_typeface.addUnicodeRange(range.toString());
|
||||
}
|
||||
|
||||
private void addGlyphToTypeface(GlyphFile a_file) throws FileNotFoundException {
|
||||
private void addGlyphToTypeface(GlyphFile a_file) {
|
||||
m_typeface.addGlyph(a_file);
|
||||
|
||||
setRoot(a_file);
|
||||
}
|
||||
|
||||
public GlyphFile openGlyphFile(String a_fileName) {
|
||||
ModuleManager manager = ModuleManager.getSingletonInstance();
|
||||
GlyphFile retval = manager.getReloadedGlyphFile(a_fileName);
|
||||
setRoot(retval);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
public void removeGlyphFromTypeface(String a_fileName) {
|
||||
public void buildTrueType() {
|
||||
if (m_typeface == null)
|
||||
return;
|
||||
|
||||
m_typeface.removeGlyph(a_fileName);
|
||||
}
|
||||
|
||||
public Font buildTrueType(boolean a_isDebug) {
|
||||
Font retval = null;
|
||||
|
||||
if (m_typeface == null)
|
||||
return retval;
|
||||
|
||||
|
||||
|
||||
try {
|
||||
m_typeface.buildTTF(a_isDebug);
|
||||
retval = m_typeface.getFont();
|
||||
m_typeface.buildTTF();
|
||||
m_typeface.getFont();
|
||||
} catch (Exception e) {
|
||||
Logger.getLogger(Engine.class.getName()).log(Level.SEVERE, null,e);
|
||||
} // try-catch
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
public void saveGlyph() throws FileNotFoundException {
|
||||
if (m_root == null)
|
||||
return;
|
||||
|
||||
if (m_root.getGlyphTitle().equals("")) {
|
||||
Logger.getLogger(Engine.class.getName()).log(Level.SEVERE, m_msgEmptyGlyphTitle);
|
||||
return;
|
||||
} // if
|
||||
return;
|
||||
}
|
||||
|
||||
public TypefaceFile getTypeface() {
|
||||
@@ -501,84 +154,69 @@ public class Engine {
|
||||
m_root = a_file;
|
||||
}
|
||||
|
||||
public String includeFileName() {
|
||||
String retval = "";
|
||||
|
||||
JFileChooser chooser = new JFileChooser(getGlyphPath());
|
||||
chooser.setFileFilter(new GlyphFileFilter());
|
||||
|
||||
int returnVal = chooser.showOpenDialog(null);
|
||||
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
retval = chooser.getSelectedFile().getName().toString();
|
||||
} // if
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
public void addCodePage(String a_codePage) throws FileNotFoundException {
|
||||
public void addCodePage(String a_codePage) {
|
||||
if (m_typeface == null) {
|
||||
return;
|
||||
} // if
|
||||
}
|
||||
|
||||
m_typeface.addCodePage(a_codePage);
|
||||
}
|
||||
|
||||
public void removeCodePage(String a_codePage) throws FileNotFoundException {
|
||||
public void removeCodePage(String a_codePage) {
|
||||
if (m_typeface == null) {
|
||||
return;
|
||||
} // if
|
||||
}
|
||||
|
||||
m_typeface.removeCodePage(a_codePage);
|
||||
}
|
||||
|
||||
public void setAuthor(String a_value) throws FileNotFoundException {
|
||||
public void setAuthor(String a_value) {
|
||||
if (m_typeface == null) {
|
||||
return;
|
||||
} // if
|
||||
}
|
||||
|
||||
m_typeface.setAuthor(a_value);
|
||||
}
|
||||
|
||||
public void setCopyrightYear(String a_value) throws FileNotFoundException {
|
||||
public void setCopyrightYear(String a_value) {
|
||||
if (m_typeface == null) {
|
||||
return;
|
||||
} // if
|
||||
}
|
||||
|
||||
m_typeface.setCopyrightYear(a_value);
|
||||
}
|
||||
|
||||
public void setFontFamilyName(String a_value) throws FileNotFoundException {
|
||||
public void setFontFamilyName(String a_value) {
|
||||
if (m_typeface == null) {
|
||||
return;
|
||||
} // if
|
||||
}
|
||||
|
||||
m_typeface.setFontFamilyName(a_value);
|
||||
}
|
||||
|
||||
public void setTypefaceLicense(String a_value) throws FileNotFoundException {
|
||||
public void setTypefaceLicense(String a_value) {
|
||||
if (m_typeface == null) {
|
||||
return;
|
||||
} // if
|
||||
}
|
||||
|
||||
m_typeface.setLicense(a_value);
|
||||
}
|
||||
|
||||
public void setBaseline(double a_value) throws FileNotFoundException {
|
||||
public void setBaseline(double a_value) {
|
||||
if (m_typeface == null) {
|
||||
return;
|
||||
} // if
|
||||
}
|
||||
|
||||
double min = m_typeface.getBottomSideBearing();
|
||||
double max = m_typeface.getMeanline();
|
||||
|
||||
if (a_value < min) {
|
||||
a_value = min;
|
||||
} // if
|
||||
}
|
||||
|
||||
if (a_value > max) {
|
||||
a_value = max;
|
||||
} // if
|
||||
}
|
||||
|
||||
try {
|
||||
m_typeface.setDescender(a_value - min);
|
||||
@@ -591,10 +229,10 @@ public class Engine {
|
||||
} // try-catch
|
||||
}
|
||||
|
||||
public void setMeanline(double a_value) throws FileNotFoundException {
|
||||
public void setMeanline(double a_value) {
|
||||
if (m_typeface == null) {
|
||||
return;
|
||||
} // if
|
||||
}
|
||||
|
||||
double min = m_typeface.getBaseline();
|
||||
double max = m_typeface.getEm()
|
||||
@@ -602,11 +240,11 @@ public class Engine {
|
||||
|
||||
if (a_value < min) {
|
||||
a_value = min;
|
||||
} // if
|
||||
}
|
||||
|
||||
if (a_value > max) {
|
||||
a_value = max;
|
||||
} // if
|
||||
}
|
||||
|
||||
try {
|
||||
m_typeface.setXHeight(a_value - min);
|
||||
@@ -615,83 +253,4 @@ public class Engine {
|
||||
e.printStackTrace();
|
||||
} // try-catch
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent a_event) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void mouseDragged(MouseEvent a_event) {
|
||||
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent a_event) {
|
||||
|
||||
}
|
||||
|
||||
public void setAction(String a_key) {
|
||||
|
||||
}
|
||||
|
||||
public void keyPressed(KeyEvent a_event) {
|
||||
if (a_event.getModifiers() == 0) {
|
||||
if (a_event.getKeyCode() == KeyEvent.VK_TAB) {
|
||||
|
||||
m_selectNextAction.actionPerformed(null);
|
||||
} // if
|
||||
} else if (a_event.getModifiers() == KeyEvent.SHIFT_MASK) {
|
||||
|
||||
} // if
|
||||
}
|
||||
|
||||
private JFileChooser createImageChooser() {
|
||||
JFileChooser retval;
|
||||
|
||||
retval = new JFileChooser(new File(AppSettings.getLastTypefaceDir()));
|
||||
retval.setFileFilter(new javax.swing.filechooser.FileFilter() {
|
||||
public boolean accept(File a_file) {
|
||||
if (a_file.isDirectory())
|
||||
return true;
|
||||
|
||||
String s = a_file.toString().toLowerCase();
|
||||
if (s.endsWith(".gif")
|
||||
|| s.endsWith(".jpg")
|
||||
|| s.endsWith(".jpeg")
|
||||
|| s.endsWith(".png"))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//The description of this filter
|
||||
public String getDescription() {
|
||||
return "Image Files";
|
||||
}
|
||||
});
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public ArrayList<TTPixelSize> getPixelSizes() {
|
||||
return TTPixelSize.getList();
|
||||
}
|
||||
|
||||
class MyTreeListener implements TreeSelectionListener {
|
||||
public void valueChanged(TreeSelectionEvent a_event) {
|
||||
TreePath path = a_event.getPath();
|
||||
Object obj = path.getLastPathComponent();
|
||||
String s = obj.toString();
|
||||
|
||||
TreePath parent = path.getParentPath();
|
||||
if (parent != null) {
|
||||
obj = parent.getLastPathComponent();
|
||||
s = obj.toString() + "->" + s;
|
||||
} // if
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* $Id: GlyphColor.java,v 1.6 2004/07/11 06:25:11 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class GlyphColor {
|
||||
public static Color MAROON = new Color(120, 21, 11);
|
||||
public static Color ORANGE = new Color(231, 113, 18); // (238, 176, 55);
|
||||
public static Color OLIVE = new Color(98, 106, 7);
|
||||
public static Color INDIGO = new Color(22, 16, 149);
|
||||
public static Color GREEN = new Color(21, 142, 5);
|
||||
public static Color RED = new Color(250, 0, 0);
|
||||
public static Color GRAY = new Color(0x33, 0x33, 0x33);
|
||||
public static Color CYAN = new Color(15, 187, 157); // 15, 108, 140
|
||||
public static Color AZURE = new Color(0x00, 0x66, 0xcc);
|
||||
public static Color TAN = new Color(0xcc, 0x99, 0x66);
|
||||
public static Color SILVER = new Color(0xe0, 0xdf, 0xe3);
|
||||
|
||||
|
||||
public static Color BACKGROUND = Color.WHITE;
|
||||
public static Color CROSS = Color.LIGHT_GRAY;
|
||||
public static Color POINT = ORANGE;
|
||||
public static Color NUMBER = Color.GRAY;
|
||||
public static Color SELECTED = RED;
|
||||
public static Color CONTOUR = AZURE;
|
||||
public static Color HINT = OLIVE;
|
||||
public static Color INCLUDE = OLIVE;
|
||||
public static Color MODULE = MAROON;
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* $Id: GlyphFileFilter.java,v 1.2 2004/01/20 03:35:27 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003-2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa;
|
||||
|
||||
import java.io.File;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class GlyphFileFilter extends FileFilter {
|
||||
public boolean accept(File a_file) {
|
||||
if (a_file.isDirectory()) {
|
||||
return false;
|
||||
} // if
|
||||
|
||||
if (! (a_file.toString().toLowerCase().endsWith(".glyph")))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//The description of this filter
|
||||
public String getDescription() {
|
||||
return "glyph files";
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
* $Id: ImageSizer.java,v 1.1 2004/03/04 12:52:50 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003-2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class ImageSizer {
|
||||
private Dimension m_size = new Dimension(-1, -1);
|
||||
private boolean m_isImcomplete;
|
||||
|
||||
private ImageObserver m_observer = new ImageObserver() {
|
||||
public synchronized boolean imageUpdate(
|
||||
Image a_image,
|
||||
int a_flag,
|
||||
int a_x,
|
||||
int a_y,
|
||||
int a_width,
|
||||
int a_height) {
|
||||
if ((a_flag & WIDTH) != 0)
|
||||
m_size.width = a_width;
|
||||
if ((a_flag & HEIGHT) != 0)
|
||||
m_size.height = a_height;
|
||||
if ((a_flag & (ERROR | ABORT)) != 0)
|
||||
m_isImcomplete = true;
|
||||
|
||||
boolean retval = !resultKnown();
|
||||
if (!retval) {
|
||||
notifyAll();
|
||||
} // if
|
||||
|
||||
return retval;
|
||||
}
|
||||
};
|
||||
|
||||
public ImageSizer(Image a_image) {
|
||||
m_size.width = a_image.getWidth(m_observer);
|
||||
m_size.height = a_image.getHeight(m_observer);
|
||||
}
|
||||
|
||||
private boolean resultKnown() {
|
||||
return m_size.width != -1
|
||||
&& m_size.height != -1
|
||||
|| m_isImcomplete;
|
||||
}
|
||||
|
||||
//returns null iff error or abort
|
||||
public Dimension getImageSize() throws InterruptedException {
|
||||
synchronized (m_observer) {
|
||||
while (!resultKnown())
|
||||
m_observer.wait();
|
||||
return m_isImcomplete ? null : new Dimension(m_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* $Id: Memento.java,v 1.1 2004/09/05 17:08:03 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003 - 2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.zip.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class Memento {
|
||||
private String m_description;
|
||||
private byte [] m_compressed;
|
||||
private int m_originalSize;
|
||||
private long m_entryTime;
|
||||
|
||||
public Memento(String a_description, byte [] a_data) {
|
||||
m_description = a_description;
|
||||
m_originalSize = a_data.length;
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
ZipOutputStream zip = new ZipOutputStream(out);
|
||||
|
||||
try {
|
||||
zip.putNextEntry(new ZipEntry(a_description));
|
||||
zip.write(a_data);
|
||||
zip.closeEntry();
|
||||
zip.close();
|
||||
}
|
||||
catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
|
||||
m_compressed = out.toByteArray();
|
||||
m_entryTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public InputStream getData() {
|
||||
ZipInputStream zip = null;
|
||||
|
||||
try {
|
||||
zip = new ZipInputStream(
|
||||
new ByteArrayInputStream(m_compressed));
|
||||
ZipEntry entry = zip.getNextEntry();
|
||||
}
|
||||
catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
|
||||
return zip;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return m_description;
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
* $Id: ModuleManager.java,v 1.5 2004/01/14 06:49:39 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa;
|
||||
|
||||
import java.util.*;
|
||||
import org.doubletype.ossa.module.*;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class ModuleManager {
|
||||
private static ModuleManager s_singleton = null;
|
||||
|
||||
public static ModuleManager getSingletonInstance() {
|
||||
if (s_singleton == null)
|
||||
s_singleton = new ModuleManager();
|
||||
return s_singleton;
|
||||
}
|
||||
|
||||
|
||||
private Hashtable<String,GlyphModule> m_modules = new Hashtable<>();
|
||||
private Hashtable<String,GlyphFile> m_files = new Hashtable<>();
|
||||
|
||||
private ModuleManager() {
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
m_modules.clear();
|
||||
m_files.clear();
|
||||
}
|
||||
|
||||
public GlyphModule getModule(String a_name) throws Exception {
|
||||
if (m_modules.containsKey(a_name)) {
|
||||
return (GlyphModule) m_modules.get(a_name);
|
||||
} // if
|
||||
|
||||
GlyphModule retval;
|
||||
|
||||
retval = (GlyphModule) Class.forName(a_name).newInstance();
|
||||
m_modules.put(a_name, retval);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
public GlyphFile getGlyphFile(String a_name) {
|
||||
if (m_files.containsKey(a_name)) {
|
||||
return (GlyphFile) m_files.get(a_name);
|
||||
} // if
|
||||
|
||||
return getReloadedGlyphFile(a_name);
|
||||
}
|
||||
|
||||
public GlyphFile getReloadedGlyphFile(String a_name) {
|
||||
GlyphFile retval;
|
||||
|
||||
Engine engine = Engine.getSingletonInstance();
|
||||
retval = new GlyphFile(new File(engine.getGlyphPath(), a_name));
|
||||
m_files.put(a_name, retval);
|
||||
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* $Id: MyTableModel.java,v 1.1 2004/02/09 05:34:17 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003-2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa;
|
||||
|
||||
import javax.swing.table.*;
|
||||
import org.doubletype.ossa.module.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class MyTableModel extends AbstractTableModel {
|
||||
protected Engine m_engine;
|
||||
protected GlyphFile m_file = null;
|
||||
|
||||
protected MyTableModel(Engine a_engine) {
|
||||
m_engine = a_engine;
|
||||
}
|
||||
|
||||
public int getColumnCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
public int getRowCount() {
|
||||
reset();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Object getValueAt(int a_row, int a_column) {
|
||||
reset();
|
||||
|
||||
Object retval = null;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
protected void reset() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* $Id: Renderer.java,v 1.1 2004/06/18 09:14:01 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public interface Renderer {
|
||||
boolean isRenderNeeded();
|
||||
void render(java.awt.Graphics2D a_graphics);
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package org.doubletype.ossa;
|
||||
|
||||
public interface Tabbable {
|
||||
boolean isClosable();
|
||||
}
|
||||
@@ -1,188 +0,0 @@
|
||||
// http://forums.sun.com/thread.jspa?forumID=257&threadID=453521
|
||||
|
||||
package org.doubletype.ossa;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
|
||||
import javax.swing.plaf.basic.BasicTabbedPaneUI;
|
||||
|
||||
public class TabbedPaneCloseButtonUI extends BasicTabbedPaneUI {
|
||||
private final int k_xButtonOffset = 19;
|
||||
private final int k_yButtonOffset = 4;
|
||||
private final int k_wButton = 14; // was 13
|
||||
private final int k_hButton = 13; // was 12
|
||||
|
||||
private int m_lastKnownSelected = -1;
|
||||
private Color m_red = new Color(217, 76, 74);
|
||||
private Color m_selectedColor = Color.white;
|
||||
private Color m_unselectedColor = new Color(160, 197, 241);
|
||||
|
||||
public TabbedPaneCloseButtonUI() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected)
|
||||
{
|
||||
if (isSelected)
|
||||
{
|
||||
g.setColor(m_selectedColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
g.setColor(m_unselectedColor);
|
||||
}
|
||||
|
||||
g.fillRect(x, y, w, h);
|
||||
}
|
||||
|
||||
protected int calculateTabHeight(int tabPlacement, int tabIndex, int fontHeight)
|
||||
{
|
||||
return fontHeight + 4;
|
||||
}
|
||||
|
||||
protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected)
|
||||
{
|
||||
g.setColor(darkShadow);
|
||||
g.drawLine(x, y + h - 2, x, y);
|
||||
g.drawLine(x, y, x + w, y);
|
||||
g.drawLine(x + w, y + h - 2, x + w, y);
|
||||
}
|
||||
|
||||
protected void paintTab(Graphics g, int tabPlacement, Rectangle[] rects,
|
||||
int tabIndex, Rectangle iconRect, Rectangle textRect) {
|
||||
|
||||
super.paintTab(g, tabPlacement, rects, tabIndex, iconRect, textRect);
|
||||
}
|
||||
|
||||
protected void paintFocusIndicator(Graphics g, int tabPlacement, Rectangle[] rects, int tabIndex, Rectangle iconRect, Rectangle textRect, boolean isSelected)
|
||||
{
|
||||
}
|
||||
|
||||
protected void paintContentBorderTopEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h)
|
||||
{
|
||||
if (selectedIndex < 0) {
|
||||
return;
|
||||
} // if
|
||||
|
||||
Rectangle rect = getTabBounds(selectedIndex, calcRect);
|
||||
g.setColor(darkShadow);
|
||||
g.drawLine(x, y, rect.x, y);
|
||||
g.drawLine(rect.x + rect.width, y, x + w, y);
|
||||
g.setColor(m_selectedColor);
|
||||
g.drawLine(rect.x + 1, y, rect.x + rect.width -1, y);
|
||||
}
|
||||
|
||||
protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h)
|
||||
{
|
||||
}
|
||||
|
||||
protected void paintContentBorderRightEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h)
|
||||
{
|
||||
}
|
||||
|
||||
protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h)
|
||||
{
|
||||
}
|
||||
|
||||
protected void paintText(Graphics g, int tabPlacement, java.awt.Font font, FontMetrics metrics, int tabIndex, String title, Rectangle textRect, boolean isSelected)
|
||||
{
|
||||
if (tabPane.getComponentAt(tabIndex) instanceof Tabbable) {
|
||||
Tabbable tabbable = (Tabbable) tabPane.getComponentAt(tabIndex);
|
||||
if (!tabbable.isClosable()) {
|
||||
super.paintText(g, tabPlacement, font, metrics, tabIndex, title, textRect, isSelected);
|
||||
return;
|
||||
} // if
|
||||
} // if
|
||||
|
||||
if (isSelected) // isSelected
|
||||
{
|
||||
super.paintText(g, tabPlacement, font, metrics, tabIndex, title, textRect, isSelected);
|
||||
Rectangle rect = rects[tabIndex];
|
||||
g.setColor(m_red);
|
||||
int xButton = rect.x + rect.width - k_xButtonOffset; // -19
|
||||
int yButton = rect.y + k_yButtonOffset; // +4
|
||||
g.fillRect(xButton, yButton, k_wButton, k_hButton);
|
||||
g.setColor(Color.white);
|
||||
g.drawLine(xButton + 3, rect.y + 7, xButton + 9, rect.y + 13);
|
||||
g.drawLine(xButton + 9, rect.y + 7, xButton + 3, rect.y + 13);
|
||||
g.drawLine(xButton + 4, rect.y + 7, xButton + 10, rect.y + 13);
|
||||
g.drawLine(xButton + 10, rect.y + 7, xButton + 4, rect.y + 13);
|
||||
|
||||
m_lastKnownSelected = tabIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
super.paintText(g, tabPlacement, font, metrics, tabIndex, title, textRect, isSelected);
|
||||
}
|
||||
}
|
||||
|
||||
protected int calculateTabWidth(int tabPlacement, int tabIndex,
|
||||
FontMetrics metrics) {
|
||||
if (tabPane.getComponentAt(tabIndex) instanceof Tabbable) {
|
||||
Tabbable tabbable = (Tabbable) tabPane.getComponentAt(tabIndex);
|
||||
if (!tabbable.isClosable()) {
|
||||
return super.calculateTabWidth(tabPlacement, tabIndex, metrics);
|
||||
} // if
|
||||
} // if
|
||||
|
||||
return super.calculateTabWidth(tabPlacement, tabIndex, metrics) + 34; // +24
|
||||
}
|
||||
|
||||
protected MouseListener createMouseListener() {
|
||||
return new MyMouseHandler();
|
||||
}
|
||||
|
||||
class MyMouseHandler extends MouseHandler {
|
||||
private int m_selectedOnPressed = -1;
|
||||
|
||||
public MyMouseHandler() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent e) {
|
||||
m_selectedOnPressed = m_lastKnownSelected;
|
||||
super.mousePressed(e);
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
int x = e.getX();
|
||||
int y = e.getY();
|
||||
int tabIndex = -1;
|
||||
int tabCount = tabPane.getTabCount();
|
||||
for (int i = 0; i < tabCount; i++) {
|
||||
if (rects[i].contains(x, y)) {
|
||||
tabIndex = i;
|
||||
break;
|
||||
} // if
|
||||
} // for i
|
||||
|
||||
// skip if this is not current.
|
||||
if (tabPane.getSelectedIndex() != tabIndex) {
|
||||
return;
|
||||
} // if
|
||||
|
||||
if (m_selectedOnPressed != tabIndex) {
|
||||
return;
|
||||
} // if
|
||||
|
||||
if (tabIndex >= 0 && !e.isPopupTrigger()) {
|
||||
Rectangle tabRect = rects[tabIndex];
|
||||
y = y - tabRect.y;
|
||||
|
||||
int xButton = tabRect.x + tabRect.width - k_xButtonOffset;
|
||||
if ((x >= xButton + 1)
|
||||
&& (x <= xButton + k_wButton - 2)
|
||||
&& (y >= k_yButtonOffset + 1)
|
||||
&& (y <= k_yButtonOffset + k_hButton - 2)) {
|
||||
tabPane.remove(tabIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* $Id: TypefaceFileFilter.java,v 1.1 2004/01/20 03:35:27 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003-2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa;
|
||||
|
||||
import java.io.File;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class TypefaceFileFilter extends FileFilter {
|
||||
public boolean accept(File a_file) {
|
||||
if (a_file.isDirectory())
|
||||
return true;
|
||||
|
||||
if (! (a_file.toString().toLowerCase().endsWith(".dtyp")))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//The description of this filter
|
||||
public String getDescription() {
|
||||
return "typeface files";
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
/*
|
||||
*/
|
||||
package org.doubletype.ossa;
|
||||
|
||||
import org.doubletype.ossa.adapter.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public interface UiBridge {
|
||||
void showPropertyDialog(GlyphObject a_object);
|
||||
}
|
||||
@@ -1,184 +0,0 @@
|
||||
/*
|
||||
* $Id: UnicodeBuilder.java,v 1.1 2004/09/11 10:09:07 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.CharacterCodingException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class UnicodeBuilder {
|
||||
public static final String k_jisCharset = "ISO-2022-JP";
|
||||
|
||||
/**
|
||||
* pops dialog and asks user for unicode.
|
||||
* @return true on success, false otherwise.
|
||||
*/
|
||||
public static Long askUnicode() {
|
||||
Engine engine = Engine.getSingletonInstance();
|
||||
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public static Long build(String a_value, int a_option) {
|
||||
if (a_value == null
|
||||
|| a_value.length() == 0) {
|
||||
return null;
|
||||
} // if
|
||||
|
||||
switch (a_option) {
|
||||
case Engine.SEARCH_BY_EXAMPLE: {
|
||||
return buildByExample(a_value);
|
||||
} // case
|
||||
|
||||
case Engine.SEARCH_UNICODE: {
|
||||
return buildByUnicode(a_value);
|
||||
} // case
|
||||
|
||||
case Engine.SEARCH_JIS_CODE: {
|
||||
return buildByJisCode(a_value);
|
||||
} // case
|
||||
} // switch
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Long buildByExample(String a_value) {
|
||||
if (a_value.length() > 1) {
|
||||
return null;
|
||||
} // if
|
||||
|
||||
return new Long((long) a_value.charAt(0));
|
||||
}
|
||||
|
||||
private static Long buildByUnicode(String a_value) {
|
||||
if (a_value.length() == 1) {
|
||||
return buildByExample(a_value);
|
||||
} // if
|
||||
|
||||
try {
|
||||
return new Long(Long.parseLong(a_value, 16));
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.getLogger(Engine.class.getName()).log(Level.SEVERE, null,e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Long buildByJisCode(String a_value) {
|
||||
if (a_value.length() == 1) {
|
||||
return buildByExample(a_value);
|
||||
} // if
|
||||
|
||||
try {
|
||||
Long retval = jisX0208ToUnicode(Long.parseLong(a_value, 16));
|
||||
|
||||
if (retval == null) {
|
||||
Logger.getLogger(Engine.class.getName()).log(Level.SEVERE, "Bad JIS Code.");
|
||||
} // if
|
||||
|
||||
return retval;
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.getLogger(Engine.class.getName()).log(Level.SEVERE, null, e);
|
||||
} // try
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* converts JIS X0208 code into unicode using ISO-2022-JP decoder.
|
||||
* @param a_value JIS code
|
||||
* @return unicode
|
||||
*/
|
||||
public static Long jisX0208ToUnicode(long a_value) {
|
||||
if (!isJisSupported()) {
|
||||
return null;
|
||||
} // if
|
||||
|
||||
Charset jis = Charset.forName(k_jisCharset);
|
||||
ByteBuffer in = ByteBuffer.allocate(5);
|
||||
CharsetDecoder jisDecoder;
|
||||
jisDecoder = jis.newDecoder();
|
||||
|
||||
long high = (0xff00 & a_value) >> 8;
|
||||
long low = 0x00ff & a_value;
|
||||
|
||||
if (high < 0x21 || high > 0x7e || low < 0x21 || high > 0x7e) {
|
||||
return null;
|
||||
} // if
|
||||
|
||||
char c = (char) a_value;
|
||||
|
||||
in.rewind();
|
||||
in.put((byte) 0x1b);
|
||||
in.put((byte) 0x24);
|
||||
in.put((byte) 0x40);
|
||||
|
||||
in.putChar(c);
|
||||
in.position(0);
|
||||
|
||||
try {
|
||||
CharBuffer out = jisDecoder.decode(in);
|
||||
if (out.length() > 0) {
|
||||
return new Long(out.get(0));
|
||||
} // if
|
||||
} catch (CharacterCodingException e) {
|
||||
e.printStackTrace();
|
||||
} // try-catch
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isJisSupported() {
|
||||
return Charset.isSupported(k_jisCharset);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public UnicodeBuilder() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,398 +1,200 @@
|
||||
/*
|
||||
* $Id: CubicSegment.java,v 1.2 2004/12/27 04:56:02 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.adapter;
|
||||
|
||||
import java.util.*;
|
||||
import java.awt.geom.*;
|
||||
|
||||
import org.doubletype.ossa.xml.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class CubicSegment {
|
||||
public static final int LINE = 0;
|
||||
public static final int CURVE = 1;
|
||||
|
||||
private static final double k_tolerance = 5;
|
||||
private static final double k_minTolerance = 10;
|
||||
private static final int k_maxTrial = 3;
|
||||
|
||||
/**
|
||||
* converts cubic contour into cubic segments.
|
||||
* @param a_contour
|
||||
* @return
|
||||
*/
|
||||
public static ArrayList<CubicSegment> toSegments(EContour a_contour) {
|
||||
ArrayList<CubicSegment> retval = new ArrayList<>();
|
||||
XContourPoint [] points = a_contour.getContourPoint();
|
||||
if (points.length < 2) {
|
||||
return retval;
|
||||
} // if
|
||||
|
||||
EContourPoint startPoint = (EContourPoint) points[points.length - 1];
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
EContourPoint endPoint = (EContourPoint) points[i];
|
||||
retval.add(new CubicSegment(startPoint, endPoint));
|
||||
startPoint = endPoint;
|
||||
} // for
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* converts cubic segments into cubic contour.
|
||||
* @param a_segments
|
||||
* @return
|
||||
*/
|
||||
public static EContour toContour(ArrayList a_segments) {
|
||||
EContour retval = new EContour();
|
||||
retval.setType(EContour.k_cubic);
|
||||
|
||||
EControlPoint controlPoint1 = null;
|
||||
for (int i = 0; i < a_segments.size(); i++) {
|
||||
CubicSegment segment = (CubicSegment) a_segments.get(i);
|
||||
EContourPoint startPoint = (EContourPoint) segment.m_startPoint.clone();
|
||||
|
||||
if (controlPoint1 != null) {
|
||||
startPoint.setControlPoint1(controlPoint1);
|
||||
controlPoint1 = null;
|
||||
} // if
|
||||
|
||||
if (segment.m_controlPoint1 != null) {
|
||||
EControlPoint controlPoint2 = new EControlPoint(false,
|
||||
segment.m_controlPoint1.getX(),
|
||||
segment.m_controlPoint1.getY());
|
||||
startPoint.setControlPoint2(controlPoint2);
|
||||
} // if
|
||||
|
||||
retval.addContourPoint(startPoint);
|
||||
|
||||
if (segment.m_controlPoint2 != null) {
|
||||
controlPoint1 = new EControlPoint(true,
|
||||
segment.m_controlPoint2.getX(),
|
||||
segment.m_controlPoint2.getY());
|
||||
}
|
||||
} // for i
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
private EContourPoint m_startPoint = null;
|
||||
private EContourPoint m_controlPoint1 = null;
|
||||
private EContourPoint m_controlPoint2 = null;
|
||||
private EContourPoint m_endPoint = null;
|
||||
|
||||
private int m_type = LINE;
|
||||
|
||||
|
||||
public CubicSegment(EContourPoint a_startPoint, EContourPoint a_endPoint) {
|
||||
m_startPoint = a_startPoint;
|
||||
m_endPoint = a_endPoint;
|
||||
|
||||
if ((!a_startPoint.hasControlPoint2()) && (!a_endPoint.hasControlPoint1())) {
|
||||
m_type = LINE;
|
||||
return;
|
||||
} // if
|
||||
|
||||
if (a_startPoint.hasControlPoint2() || a_endPoint.hasControlPoint1()) {
|
||||
m_type = CURVE;
|
||||
|
||||
if (a_startPoint.hasControlPoint2()) {
|
||||
m_controlPoint1 = (EContourPoint) a_startPoint.getControlPoint2().getContourPoint();
|
||||
} else {
|
||||
m_controlPoint1 = a_startPoint;
|
||||
} // if-else
|
||||
|
||||
if (a_endPoint.hasControlPoint1()) {
|
||||
m_controlPoint2 = (EContourPoint) a_endPoint.getControlPoint1().getContourPoint();
|
||||
} else {
|
||||
m_controlPoint2 = a_endPoint;
|
||||
} // if-else
|
||||
} // if
|
||||
}
|
||||
|
||||
public CubicSegment(EContourPoint a_startPoint, EContourPoint a_controlPoint1,
|
||||
EContourPoint a_controlPoint2, EContourPoint a_endPoint) {
|
||||
m_startPoint = a_startPoint;
|
||||
m_controlPoint1 = a_controlPoint1;
|
||||
m_controlPoint2 = a_controlPoint2;
|
||||
m_endPoint = a_endPoint;
|
||||
m_type = CURVE;
|
||||
}
|
||||
|
||||
public ArrayList<QuadraticSegment> toQuadraticSegments() {
|
||||
ArrayList<QuadraticSegment> retval = new ArrayList<>();
|
||||
|
||||
if (m_type == LINE) {
|
||||
retval.add(new QuadraticSegment(m_startPoint, null, m_endPoint));
|
||||
return retval;
|
||||
} // if
|
||||
|
||||
return toQuadraticSegments(0);
|
||||
}
|
||||
|
||||
//JPEXS start
|
||||
private static Point2D.Double movePoint(Point2D point, double dx, double dy) {
|
||||
return new Point2D.Double(point.getX() + dx, point.getY() + dy);
|
||||
}
|
||||
|
||||
private static Point2D getMidPoint(Point2D p0, Point2D p1) {
|
||||
return getPointOnSegment(p0, p1, 0.5);
|
||||
}
|
||||
|
||||
private static Point2D getPointOnSegment(Point2D p0, Point2D p1, double ratio) {
|
||||
double x = p0.getX() + ((p1.getX() - p0.getX()) * ratio);
|
||||
double y = p0.getY() + ((p1.getY() - p0.getY()) * ratio);
|
||||
return new Point2D.Double(x, y);
|
||||
}
|
||||
private static double[][] approximateCubic(double[] cubicControlPointCoords) {
|
||||
if (cubicControlPointCoords.length < 8) {
|
||||
throw new IllegalArgumentException("Must have at least 8 coordinates");
|
||||
}
|
||||
|
||||
//extract point objects from source array
|
||||
Point2D p0 = new Point2D.Double(cubicControlPointCoords[0], cubicControlPointCoords[1]);
|
||||
Point2D p1 = new Point2D.Double(cubicControlPointCoords[2], cubicControlPointCoords[3]);
|
||||
Point2D p2 = new Point2D.Double(cubicControlPointCoords[4], cubicControlPointCoords[5]);
|
||||
Point2D p3 = new Point2D.Double(cubicControlPointCoords[6], cubicControlPointCoords[7]);
|
||||
|
||||
//calculates the useful base points
|
||||
Point2D pa = getPointOnSegment(p0, p1, 3.0 / 4.0);
|
||||
Point2D pb = getPointOnSegment(p3, p2, 3.0 / 4.0);
|
||||
|
||||
//get 1/16 of the [P3, P0] segment
|
||||
double dx = (p3.getX() - p0.getX()) / 16.0;
|
||||
double dy = (p3.getY() - p0.getY()) / 16.0;
|
||||
|
||||
//calculates control point 1
|
||||
Point2D pc1 = getPointOnSegment(p0, p1, 3.0 / 8.0);
|
||||
|
||||
//calculates control point 2
|
||||
Point2D pc2 = getPointOnSegment(pa, pb, 3.0 / 8.0);
|
||||
pc2 = movePoint(pc2, -dx, -dy);
|
||||
|
||||
//calculates control point 3
|
||||
Point2D pc3 = getPointOnSegment(pb, pa, 3.0 / 8.0);
|
||||
pc3 = movePoint(pc3, dx, dy);
|
||||
|
||||
//calculates control point 4
|
||||
Point2D pc4 = getPointOnSegment(p3, p2, 3.0 / 8.0);
|
||||
|
||||
//calculates the 3 anchor points
|
||||
Point2D pa1 = getMidPoint(pc1, pc2);
|
||||
Point2D pa2 = getMidPoint(pa, pb);
|
||||
Point2D pa3 = getMidPoint(pc3, pc4);
|
||||
|
||||
//return the points for the four quadratic curves
|
||||
return new double[][]{
|
||||
{pc1.getX(), pc1.getY(), pa1.getX(), pa1.getY()},
|
||||
{pc2.getX(), pc2.getY(), pa2.getX(), pa2.getY()},
|
||||
{pc3.getX(), pc3.getY(), pa3.getX(), pa3.getY()},
|
||||
{pc4.getX(), pc4.getY(), p3.getX(), p3.getY()}};
|
||||
}
|
||||
|
||||
//JPEXS end
|
||||
|
||||
private ArrayList<QuadraticSegment> toQuadraticSegments(int a_trial) {
|
||||
ArrayList<QuadraticSegment> retval = new ArrayList<>();
|
||||
|
||||
a_trial++;
|
||||
|
||||
double[][] quadCoords =approximateCubic(new double[]{m_startPoint.getX(),m_startPoint.getY(),m_controlPoint1.getX(),m_controlPoint1.getY(),m_controlPoint2.getX(),m_controlPoint2.getY(),m_endPoint.getX(),m_endPoint.getY()});
|
||||
EContourPoint lastPoint=m_startPoint;
|
||||
for (int i = 0; i < quadCoords.length; i++) {
|
||||
retval.add(new QuadraticSegment(
|
||||
lastPoint,
|
||||
new EContourPoint(quadCoords[i][0], quadCoords[i][1], true),
|
||||
new EContourPoint(quadCoords[i][2], quadCoords[i][3], false)));
|
||||
lastPoint = new EContourPoint(quadCoords[i][2],quadCoords[i][3],true);
|
||||
}
|
||||
/*EContourPoint intersection = calculateIntersection();
|
||||
|
||||
double deltaX = 0.125 * (m_startPoint.getX() + m_endPoint.getX() + 4 * intersection.getX()
|
||||
- 3 * (m_controlPoint1.getX() + m_controlPoint2.getX()));
|
||||
double deltaY = 0.125 * (m_startPoint.getY() + m_endPoint.getY() + 4 * intersection.getY()
|
||||
- 3 * (m_controlPoint1.getY() + m_controlPoint2.getY()));
|
||||
double deltaSqr = (deltaX * deltaX + deltaY * deltaY);
|
||||
|
||||
if (deltaSqr > (k_minTolerance * k_minTolerance)
|
||||
|| ((a_trial < k_maxTrial) && (deltaSqr > (k_tolerance * k_tolerance)))) {
|
||||
return toSplitQuadraticSegments(a_trial);
|
||||
} // if
|
||||
|
||||
retval.add(new QuadraticSegment(m_startPoint, intersection, m_endPoint));*/
|
||||
return retval;
|
||||
}
|
||||
|
||||
private ArrayList<QuadraticSegment> toSplitQuadraticSegments(int a_trial) {
|
||||
EContourPoint p01 = midPoint(m_startPoint, m_controlPoint1);
|
||||
EContourPoint p12 = midPoint(m_controlPoint1, m_controlPoint2);
|
||||
EContourPoint p23 = midPoint(m_controlPoint2, m_endPoint);
|
||||
|
||||
EContourPoint pA = midPoint(p01, p12);
|
||||
EContourPoint pB = midPoint(p12, p23);
|
||||
|
||||
EContourPoint pAB = midPoint(pA, pB);
|
||||
|
||||
CubicSegment firstCubicSegment = new CubicSegment(m_startPoint, p01, pA, pAB);
|
||||
CubicSegment secondCubicSegment = new CubicSegment(pAB, pB, p23, m_endPoint);
|
||||
|
||||
ArrayList<QuadraticSegment> firstHalf = firstCubicSegment.toQuadraticSegments(a_trial);
|
||||
ArrayList<QuadraticSegment> secondHalf = secondCubicSegment.toQuadraticSegments(a_trial);
|
||||
|
||||
firstHalf.addAll(secondHalf);
|
||||
|
||||
return firstHalf;
|
||||
}
|
||||
|
||||
private EContourPoint midPoint(EContourPoint a_start, EContourPoint a_end) {
|
||||
Point2D p = calculateMidPoint(a_start, a_end);
|
||||
EContourPoint retval = new EContourPoint(p.getX(), p.getY(), true);
|
||||
|
||||
ArrayList ppems = getPpems(a_start, a_end);
|
||||
EPoint startPoint, endPoint;
|
||||
for (int i = 0; i < ppems.size(); i++) {
|
||||
Long ppemObject = (Long) ppems.get(i);
|
||||
long ppem = ppemObject.longValue();
|
||||
|
||||
if (retval.hasHintForPpem(ppem)) {
|
||||
continue;
|
||||
} // if
|
||||
|
||||
startPoint = a_start.getHintIfPossible(ppem);
|
||||
endPoint = a_end.getHintIfPossible(ppem);
|
||||
|
||||
p = calculateMidPoint(startPoint, endPoint);
|
||||
EHint hint = new EHint(p.getX(), p.getY(), ppem);
|
||||
retval.addHint(hint);
|
||||
} // for i
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
private Point2D calculateMidPoint(EPoint a_p1, EPoint a_p2) {
|
||||
Point2D retval = new Point2D.Double((a_p1.getX() + a_p2.getX()) / 2.0,
|
||||
(a_p1.getY() + a_p2.getY()) / 2.0);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* calculate intersection of line (a_start, a_controlPoint1) and
|
||||
* line (a_end, a_controlPoint2)
|
||||
* @return
|
||||
*/
|
||||
private EContourPoint calculateIntersection() {
|
||||
EContourPoint retval = new EContourPoint(m_startPoint.getX(), m_startPoint.getY(), false);
|
||||
Point2D intersection = calculateIntersection(m_startPoint, m_controlPoint1, m_controlPoint2, m_endPoint);
|
||||
retval.getPoint2d().setX(intersection.getX());
|
||||
retval.getPoint2d().setY(intersection.getY());
|
||||
|
||||
EPoint startPoint, controlPoint1, controlPoint2, endPoint;
|
||||
ArrayList ppems = getPpems(m_startPoint, m_controlPoint1, m_controlPoint2, m_endPoint);
|
||||
for (int i = 0; i < ppems.size(); i++) {
|
||||
Long ppemObject = (Long) ppems.get(i);
|
||||
long ppem = ppemObject.longValue();
|
||||
|
||||
if (retval.hasHintForPpem(ppem)) {
|
||||
continue;
|
||||
} // if
|
||||
|
||||
startPoint = m_startPoint.getHintIfPossible(ppem);
|
||||
controlPoint1 = m_controlPoint1.getHintIfPossible(ppem);
|
||||
controlPoint2 = m_controlPoint2.getHintIfPossible(ppem);
|
||||
endPoint = m_endPoint.getHintIfPossible(ppem);
|
||||
|
||||
Point2D p = calculateIntersection(startPoint, controlPoint1, controlPoint2, endPoint);
|
||||
EHint hint = new EHint(p.getX(), p.getY(), ppem);
|
||||
retval.addHint(hint);
|
||||
} // for i
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
private Point2D calculateIntersection(EPoint a_p1, EPoint a_p2, EPoint a_p3, EPoint a_p4) {
|
||||
Point2D retval = new Point2D.Double(a_p1.getX(), a_p1.getY());
|
||||
|
||||
double deltaX1 = a_p2.getX() - a_p1.getX();
|
||||
double deltaX2 = a_p3.getX() - a_p4.getX();
|
||||
if (deltaX1 == 0) {
|
||||
deltaX1 = 0.1;
|
||||
} // if
|
||||
if (deltaX2 == 0) {
|
||||
deltaX2 = 0.2;
|
||||
} // if
|
||||
|
||||
double incline1 = (a_p2.getY() - a_p1.getY()) / deltaX1;
|
||||
double incline2 = (a_p3.getY() - a_p4.getY()) / deltaX2;
|
||||
if (incline1 == incline2) {
|
||||
return retval;
|
||||
} // if
|
||||
|
||||
double x = (-incline2 * a_p4.getX() + a_p4.getY()
|
||||
+incline1 * a_p1.getX() - a_p1.getY()) / (incline1 - incline2);
|
||||
double y = incline1 * (x - a_p1.getX()) + a_p1.getY();
|
||||
|
||||
retval.setLocation(x, y);
|
||||
return retval;
|
||||
}
|
||||
|
||||
private ArrayList<Long> getPpems(EContourPoint a_start, EContourPoint a_end) {
|
||||
ArrayList<Long> retval = new ArrayList<>();
|
||||
collectPpemsFromHints(retval, a_start.getHint());
|
||||
collectPpemsFromHints(retval, a_end.getHint());
|
||||
return retval;
|
||||
}
|
||||
|
||||
private void collectPpemsFromHints(ArrayList<Long> a_ppems, XHint[] a_hints) {
|
||||
for (XHint hint: a_hints) {
|
||||
if (!a_ppems.contains(hint.getPpem())) {
|
||||
a_ppems.add(hint.getPpem());
|
||||
} // if
|
||||
} // for i
|
||||
}
|
||||
|
||||
private ArrayList<Long> getPpems(EContourPoint a_start, EContourPoint a_controlPoint1,
|
||||
EContourPoint a_controlPoint2, EContourPoint a_end) {
|
||||
ArrayList<Long> retval = new ArrayList<>();
|
||||
collectPpemsFromHints(retval, a_start.getHint());
|
||||
collectPpemsFromHints(retval, a_controlPoint1.getHint());
|
||||
collectPpemsFromHints(retval, a_controlPoint2.getHint());
|
||||
collectPpemsFromHints(retval, a_end.getHint());
|
||||
return retval;
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* $Id: CubicSegment.java,v 1.2 2004/12/27 04:56:02 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.adapter;
|
||||
|
||||
import java.util.*;
|
||||
import java.awt.geom.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class CubicSegment {
|
||||
public static final int LINE = 0;
|
||||
public static final int CURVE = 1;
|
||||
|
||||
/**
|
||||
* converts cubic contour into cubic segments.
|
||||
* @param a_contour
|
||||
* @return
|
||||
*/
|
||||
public static ArrayList<CubicSegment> toSegments(EContour a_contour) {
|
||||
ArrayList<CubicSegment> retval = new ArrayList<>();
|
||||
ArrayList<EContourPoint> points = a_contour.getContourPoints();
|
||||
if (points.size() < 2) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
EContourPoint startPoint = (EContourPoint) points.get(points.size() - 1);
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
EContourPoint endPoint = (EContourPoint) points.get(i);
|
||||
retval.add(new CubicSegment(startPoint, endPoint));
|
||||
startPoint = endPoint;
|
||||
} // for
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
private EContourPoint m_startPoint = null;
|
||||
private EContourPoint m_controlPoint1 = null;
|
||||
private EContourPoint m_controlPoint2 = null;
|
||||
private EContourPoint m_endPoint = null;
|
||||
|
||||
private int m_type = LINE;
|
||||
|
||||
|
||||
public CubicSegment(EContourPoint a_startPoint, EContourPoint a_endPoint) {
|
||||
m_startPoint = a_startPoint;
|
||||
m_endPoint = a_endPoint;
|
||||
|
||||
if ((!a_startPoint.hasControlPoint2()) && (!a_endPoint.hasControlPoint1())) {
|
||||
m_type = LINE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (a_startPoint.hasControlPoint2() || a_endPoint.hasControlPoint1()) {
|
||||
m_type = CURVE;
|
||||
|
||||
if (a_startPoint.hasControlPoint2()) {
|
||||
m_controlPoint1 = a_startPoint.getControlPoint2().getContourPoint();
|
||||
} else {
|
||||
m_controlPoint1 = a_startPoint;
|
||||
}
|
||||
|
||||
if (a_endPoint.hasControlPoint1()) {
|
||||
m_controlPoint2 = a_endPoint.getControlPoint1().getContourPoint();
|
||||
} else {
|
||||
m_controlPoint1 = a_endPoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CubicSegment(EContourPoint a_startPoint, EContourPoint a_controlPoint1,
|
||||
EContourPoint a_controlPoint2, EContourPoint a_endPoint) {
|
||||
m_startPoint = a_startPoint;
|
||||
m_controlPoint1 = a_controlPoint1;
|
||||
m_controlPoint2 = a_controlPoint2;
|
||||
m_endPoint = a_endPoint;
|
||||
m_type = CURVE;
|
||||
}
|
||||
|
||||
public ArrayList<QuadraticSegment> toQuadraticSegments() {
|
||||
ArrayList<QuadraticSegment> retval = new ArrayList<>();
|
||||
|
||||
if (m_type == LINE) {
|
||||
retval.add(new QuadraticSegment(m_startPoint, null, m_endPoint));
|
||||
return retval;
|
||||
}
|
||||
|
||||
return toQuadraticSegments(0);
|
||||
}
|
||||
|
||||
//JPEXS start
|
||||
private static Point2D.Double movePoint(Point2D point, double dx, double dy) {
|
||||
return new Point2D.Double(point.getX() + dx, point.getY() + dy);
|
||||
}
|
||||
|
||||
private static Point2D getMidPoint(Point2D p0, Point2D p1) {
|
||||
return getPointOnSegment(p0, p1, 0.5);
|
||||
}
|
||||
|
||||
private static Point2D getPointOnSegment(Point2D p0, Point2D p1, double ratio) {
|
||||
double x = p0.getX() + ((p1.getX() - p0.getX()) * ratio);
|
||||
double y = p0.getY() + ((p1.getY() - p0.getY()) * ratio);
|
||||
return new Point2D.Double(x, y);
|
||||
}
|
||||
private static double[][] approximateCubic(double[] cubicControlPointCoords) {
|
||||
if (cubicControlPointCoords.length < 8) {
|
||||
throw new IllegalArgumentException("Must have at least 8 coordinates");
|
||||
}
|
||||
|
||||
//extract point objects from source array
|
||||
Point2D p0 = new Point2D.Double(cubicControlPointCoords[0], cubicControlPointCoords[1]);
|
||||
Point2D p1 = new Point2D.Double(cubicControlPointCoords[2], cubicControlPointCoords[3]);
|
||||
Point2D p2 = new Point2D.Double(cubicControlPointCoords[4], cubicControlPointCoords[5]);
|
||||
Point2D p3 = new Point2D.Double(cubicControlPointCoords[6], cubicControlPointCoords[7]);
|
||||
|
||||
//calculates the useful base points
|
||||
Point2D pa = getPointOnSegment(p0, p1, 3.0 / 4.0);
|
||||
Point2D pb = getPointOnSegment(p3, p2, 3.0 / 4.0);
|
||||
|
||||
//get 1/16 of the [P3, P0] segment
|
||||
double dx = (p3.getX() - p0.getX()) / 16.0;
|
||||
double dy = (p3.getY() - p0.getY()) / 16.0;
|
||||
|
||||
//calculates control point 1
|
||||
Point2D pc1 = getPointOnSegment(p0, p1, 3.0 / 8.0);
|
||||
|
||||
//calculates control point 2
|
||||
Point2D pc2 = getPointOnSegment(pa, pb, 3.0 / 8.0);
|
||||
pc2 = movePoint(pc2, -dx, -dy);
|
||||
|
||||
//calculates control point 3
|
||||
Point2D pc3 = getPointOnSegment(pb, pa, 3.0 / 8.0);
|
||||
pc3 = movePoint(pc3, dx, dy);
|
||||
|
||||
//calculates control point 4
|
||||
Point2D pc4 = getPointOnSegment(p3, p2, 3.0 / 8.0);
|
||||
|
||||
//calculates the 3 anchor points
|
||||
Point2D pa1 = getMidPoint(pc1, pc2);
|
||||
Point2D pa2 = getMidPoint(pa, pb);
|
||||
Point2D pa3 = getMidPoint(pc3, pc4);
|
||||
|
||||
//return the points for the four quadratic curves
|
||||
return new double[][]{
|
||||
{pc1.getX(), pc1.getY(), pa1.getX(), pa1.getY()},
|
||||
{pc2.getX(), pc2.getY(), pa2.getX(), pa2.getY()},
|
||||
{pc3.getX(), pc3.getY(), pa3.getX(), pa3.getY()},
|
||||
{pc4.getX(), pc4.getY(), p3.getX(), p3.getY()}};
|
||||
}
|
||||
|
||||
//JPEXS end
|
||||
|
||||
private ArrayList<QuadraticSegment> toQuadraticSegments(int a_trial) {
|
||||
ArrayList<QuadraticSegment> retval = new ArrayList<>();
|
||||
|
||||
double[][] quadCoords =approximateCubic(new double[]{m_startPoint.getX(),m_startPoint.getY(),m_controlPoint1.getX(),m_controlPoint1.getY(),m_controlPoint2.getX(),m_controlPoint2.getY(),m_endPoint.getX(),m_endPoint.getY()});
|
||||
EContourPoint lastPoint=m_startPoint;
|
||||
for (int i = 0; i < quadCoords.length; i++) {
|
||||
retval.add(new QuadraticSegment(
|
||||
lastPoint,
|
||||
new EContourPoint(quadCoords[i][0], quadCoords[i][1], true),
|
||||
new EContourPoint(quadCoords[i][2], quadCoords[i][3], false)));
|
||||
lastPoint = new EContourPoint(quadCoords[i][2],quadCoords[i][3],true);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,243 +1,86 @@
|
||||
/*
|
||||
* $Id: EContour.java,v 1.11 2004/12/17 04:13:17 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003-2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.adapter;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.doubletype.ossa.xml.*;
|
||||
import org.doubletype.ossa.*;
|
||||
import org.doubletype.ossa.module.Rectangle;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class EContour extends XContour implements GlyphObject, PointAggregate {
|
||||
public static final String k_quadratic = "quadratic";
|
||||
public static final String k_cubic = "cubic";
|
||||
public static final int k_defaultPixelSize = 16;
|
||||
|
||||
public static EContour createAt(Point2D a_point) {
|
||||
EContour retval = new EContour();
|
||||
retval.setType(k_cubic);
|
||||
|
||||
EContourPoint point;
|
||||
double x, y;
|
||||
|
||||
x = a_point.getX();
|
||||
y = a_point.getY();
|
||||
point = new EContourPoint(x, y, true);
|
||||
retval.addContourPoint(point);
|
||||
|
||||
|
||||
x += Rectangle.k_defaultPen;
|
||||
point = new EContourPoint(x, y, true);
|
||||
retval.addContourPoint(point);
|
||||
|
||||
y += Rectangle.k_defaultPen;
|
||||
point = new EContourPoint(x, y, true);
|
||||
retval.addContourPoint(point);
|
||||
|
||||
x -= Rectangle.k_defaultPen;
|
||||
point = new EContourPoint(x, y, true);
|
||||
retval.addContourPoint(point);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
public EContour() {
|
||||
initDefaults();
|
||||
}
|
||||
|
||||
public EContour(RStack a_stack) {
|
||||
super(a_stack);
|
||||
initDefaults();
|
||||
}
|
||||
|
||||
/** set default values
|
||||
*/
|
||||
private void initDefaults() {
|
||||
if (getType() == null) {
|
||||
setType(k_quadratic);
|
||||
} // if
|
||||
}
|
||||
|
||||
public boolean isCubic() {
|
||||
return getType().equals(k_cubic);
|
||||
}
|
||||
|
||||
public EContour transpose(AffineTransform a_trans) {
|
||||
EContour retval = new EContour();
|
||||
retval.setType(this.getType());
|
||||
|
||||
XContourPoint[] points = getContourPoint();
|
||||
int i;
|
||||
for (i = 0; i < points.length; i++) {
|
||||
EContourPoint point = (EContourPoint) points[i];
|
||||
retval.addContourPoint(point.transpose(a_trans));
|
||||
} // if
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
public void display(Graphics2D g, AffineTransform a_trans) {
|
||||
g.setColor(GlyphColor.CONTOUR);
|
||||
|
||||
if (isSelected()) {
|
||||
g.setColor(GlyphColor.SELECTED);
|
||||
} // if
|
||||
|
||||
int ppem =EContour.k_defaultPixelSize;
|
||||
g.draw(toShape(a_trans, ppem));
|
||||
}
|
||||
|
||||
public boolean isSelected() {
|
||||
return EObject.getActives().isSelected(this);
|
||||
}
|
||||
|
||||
public Shape toShape(AffineTransform a_trans, int a_ppem) {
|
||||
return transpose(a_trans).toShape(a_ppem);
|
||||
}
|
||||
|
||||
private Shape toShape(int a_ppem) {
|
||||
Emulator emulator = Emulator.getInstance();
|
||||
|
||||
return emulator.createShape(this, a_ppem);
|
||||
}
|
||||
|
||||
public void move(Point2D a_delta) {
|
||||
movePoints(getContourPoint(), a_delta);
|
||||
}
|
||||
|
||||
private void movePoints(XContourPoint [] a_points, Point2D a_delta) {
|
||||
int i;
|
||||
for (i = 0; i < a_points.length; i++) {
|
||||
EContourPoint point = (EContourPoint) a_points[i];
|
||||
EObject.movePoint(point, a_delta);
|
||||
} // for i
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
XBody parent = (XBody) rGetParentRNode();
|
||||
parent.removeContour(this);
|
||||
}
|
||||
|
||||
// PointAggregate
|
||||
public void removePoint(EContourPoint a_point) {
|
||||
removeContourPoint(a_point);
|
||||
|
||||
if (getContourPoint().length < 2) {
|
||||
remove();
|
||||
} // if
|
||||
}
|
||||
|
||||
// PointAggregate
|
||||
public void movePoint(EContourPoint a_point, Point2D a_delta) {
|
||||
EObject.movePoint(a_point, a_delta);
|
||||
}
|
||||
|
||||
// PointAggregate
|
||||
public GlyphObject insertPoint(EContourPoint a_point) {
|
||||
int i;
|
||||
int len = getContourPoint().length;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (getContourPoint(i) == a_point) {
|
||||
break;
|
||||
} // if
|
||||
} // for
|
||||
|
||||
EContourPoint nextPoint;
|
||||
nextPoint = (EContourPoint) getContourPoint((i + 1) % len);
|
||||
|
||||
double x = (a_point.getX() + nextPoint.getX()) / 2;
|
||||
double y = (a_point.getY() + nextPoint.getY()) / 2;
|
||||
|
||||
EContourPoint retval = new EContourPoint(x, y, true);
|
||||
addContourPoint(i + 1, retval);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
public boolean hit(Rectangle2D a_rect, AffineTransform a_trans) {
|
||||
return EObject.hit(this, a_rect, a_trans);
|
||||
}
|
||||
|
||||
public void convert() {
|
||||
XBody parent = (XBody) rGetParentRNode();
|
||||
|
||||
if (isCubic()) {
|
||||
parent.addContour(toQuadratic());
|
||||
} else {
|
||||
parent.addContour(toCubic());
|
||||
} // else
|
||||
|
||||
remove();
|
||||
}
|
||||
|
||||
public EContour toQuadratic() {
|
||||
if (!isCubic()) {
|
||||
return this;
|
||||
} // if
|
||||
|
||||
ArrayList<QuadraticSegment> quadraticSegments = new ArrayList<>();
|
||||
for (CubicSegment segment: CubicSegment.toSegments(this)) {
|
||||
quadraticSegments.addAll(segment.toQuadraticSegments());
|
||||
} // for i
|
||||
|
||||
return QuadraticSegment.toContour(quadraticSegments);
|
||||
}
|
||||
|
||||
public EContour toCubic() {
|
||||
if (isCubic()) {
|
||||
return this;
|
||||
} // if
|
||||
|
||||
ArrayList quadraticSegments = QuadraticSegment.toSegments(this);
|
||||
ArrayList<CubicSegment> cubicSegments = new ArrayList<>();
|
||||
for (int i = 0; i < quadraticSegments.size(); i++) {
|
||||
QuadraticSegment quadraticSegment = (QuadraticSegment) quadraticSegments.get(i);
|
||||
cubicSegments.add(quadraticSegment.toCubicSegment());
|
||||
} // for i
|
||||
|
||||
return CubicSegment.toContour(cubicSegments);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* $Id: EContour.java,v 1.11 2004/12/17 04:13:17 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003-2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.adapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class EContour {
|
||||
public static final String k_quadratic = "quadratic";
|
||||
public static final String k_cubic = "cubic";
|
||||
|
||||
private String type;
|
||||
private ArrayList<EContourPoint> m_contourPoints = new ArrayList<>();
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
public EContour() {
|
||||
setType(k_quadratic);
|
||||
}
|
||||
|
||||
public boolean isCubic() {
|
||||
return type.equals(k_cubic);
|
||||
}
|
||||
|
||||
public void setType(String a_type) {
|
||||
type = a_type;
|
||||
}
|
||||
|
||||
public void addContourPoint(EContourPoint a_point) {
|
||||
m_contourPoints.add(a_point);
|
||||
}
|
||||
|
||||
public ArrayList<EContourPoint> getContourPoints() {
|
||||
return m_contourPoints;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
public EContour toQuadratic() {
|
||||
if (!isCubic()) {
|
||||
return this;
|
||||
}
|
||||
|
||||
ArrayList<QuadraticSegment> quadraticSegments = new ArrayList<>();
|
||||
for (CubicSegment segment: CubicSegment.toSegments(this)) {
|
||||
quadraticSegments.addAll(segment.toQuadraticSegments());
|
||||
}
|
||||
|
||||
return QuadraticSegment.toContour(quadraticSegments);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,419 +1,100 @@
|
||||
/*
|
||||
* $Id: EContourPoint.java,v 1.10 2004/12/27 04:56:02 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.adapter;
|
||||
|
||||
import org.doubletype.ossa.*;
|
||||
import org.doubletype.ossa.xml.*;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class EContourPoint extends XContourPoint implements GlyphObject, EPoint {
|
||||
public static String k_on = "on";
|
||||
public static String k_off = "off";
|
||||
public static String k_true = "true";
|
||||
public static String k_false = "false";
|
||||
|
||||
private int m_number = 0;
|
||||
|
||||
/** offset of this from the global coord.
|
||||
* For contours, it will be 0.
|
||||
* For module invoke, it will be pos.x.
|
||||
*/
|
||||
private double m_xOffset = 0;
|
||||
private double m_yOffset = 0;
|
||||
|
||||
private Point2D m_adjusted;
|
||||
|
||||
public EContourPoint() {
|
||||
super();
|
||||
}
|
||||
|
||||
public EContourPoint(RStack a_stack) {
|
||||
super(a_stack);
|
||||
correctControlPoint();
|
||||
}
|
||||
|
||||
public EContourPoint(double a_x, double a_y, boolean a_isOn) {
|
||||
setPoint2d(new XPoint2d());
|
||||
getPoint2d().setX(a_x);
|
||||
getPoint2d().setY(a_y);
|
||||
|
||||
setOn(a_isOn);
|
||||
}
|
||||
|
||||
/** Move the second control point if it was incorrectly set to the first one.
|
||||
*
|
||||
*/
|
||||
private void correctControlPoint() {
|
||||
if (!hasControlPoint1()) {
|
||||
return;
|
||||
} // if
|
||||
|
||||
EControlPoint controlPoint = (EControlPoint) getControlPoint1();
|
||||
if (controlPoint.isFirst()) {
|
||||
return;
|
||||
} // if
|
||||
|
||||
setControlPoint2(controlPoint);
|
||||
setControlPoint1(null);
|
||||
}
|
||||
|
||||
public EContourPoint transpose(AffineTransform a_trans) {
|
||||
EContourPoint retval = new EContourPoint();
|
||||
|
||||
retval.setPoint2d(EObject.createTransform(getPoint2d(), a_trans));
|
||||
retval.setOn(isOn());
|
||||
retval.setRounded(isRounded());
|
||||
|
||||
if (hasControlPoint1()) {
|
||||
EControlPoint controlPoint = (EControlPoint) getControlPoint1();
|
||||
retval.setControlPoint1(controlPoint.transpose(a_trans));
|
||||
} // if
|
||||
if (hasControlPoint2()) {
|
||||
EControlPoint controlPoint = (EControlPoint) getControlPoint2();
|
||||
retval.setControlPoint2(controlPoint.transpose(a_trans));
|
||||
} // if
|
||||
|
||||
int i;
|
||||
XHint [] hints = getHint();
|
||||
for (i = 0; i < hints.length; i++) {
|
||||
EHint hint = (EHint) hints[i];
|
||||
retval.addHint(hint.createTransform(a_trans));
|
||||
} // for i
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
public void setNumber(int a_number) {
|
||||
m_number = a_number;
|
||||
}
|
||||
|
||||
public void setOffset(double a_x, double a_y) {
|
||||
m_xOffset = a_x;
|
||||
m_yOffset = a_y;
|
||||
}
|
||||
|
||||
private AffineTransform buildOffsetTrans(AffineTransform a_trans) {
|
||||
if (m_xOffset == 0 && m_yOffset == 0) {
|
||||
return a_trans;
|
||||
} // if
|
||||
|
||||
AffineTransform retval = (AffineTransform) a_trans.clone();
|
||||
retval.translate(m_xOffset, m_yOffset);
|
||||
|
||||
return retval;
|
||||
}
|
||||
public static final int k_defaultPixelSize = 16;
|
||||
|
||||
public void display(Graphics2D g, AffineTransform a_trans) {
|
||||
AffineTransform trans = buildOffsetTrans(a_trans);
|
||||
|
||||
int ppem = k_defaultPixelSize;
|
||||
Shape rect = toShape(trans, ppem);
|
||||
g.setColor(GlyphColor.POINT);
|
||||
if (isRounded()) {
|
||||
g.setColor(GlyphColor.GRAY);
|
||||
} // if
|
||||
|
||||
if (isSelected()) {
|
||||
g.setColor(GlyphColor.SELECTED);
|
||||
} // if
|
||||
|
||||
if (isOn())
|
||||
g.fill(rect);
|
||||
else
|
||||
g.draw(rect);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean isSelected() {
|
||||
return EObject.getActives().isSelected(this);
|
||||
}
|
||||
|
||||
public void resetAdjusted() {
|
||||
setAdjusted(getX(), getY());
|
||||
}
|
||||
|
||||
public void roundAdjusted(int a_ppem) {
|
||||
if (!isRounded()) {
|
||||
return;
|
||||
} // if
|
||||
|
||||
setAdjusted(round(getX(), a_ppem),
|
||||
round(getY(), a_ppem));
|
||||
}
|
||||
|
||||
public void hintAdjusted(int a_ppem) {
|
||||
if (!hasHintForPpem(a_ppem)) {
|
||||
return;
|
||||
} // if
|
||||
|
||||
EHint hint = getHintForPpem(a_ppem);
|
||||
setAdjusted(hint.getX(), hint.getY());
|
||||
}
|
||||
|
||||
public void setAdjusted(double a_x, double a_y) {
|
||||
m_adjusted = new Point2D.Double(a_x, a_y);
|
||||
}
|
||||
|
||||
public Point2D getAdjusted() {
|
||||
return m_adjusted;
|
||||
}
|
||||
|
||||
public Shape toShape(AffineTransform a_trans, int a_ppem) {
|
||||
return EObject.toShape(getPoint2d(), a_trans);
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return getPoint2d().getX();
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return getPoint2d().getY();
|
||||
}
|
||||
|
||||
public boolean isOn() {
|
||||
return getType().equals(k_on);
|
||||
}
|
||||
|
||||
public boolean isRounded() {
|
||||
return getRounded();
|
||||
}
|
||||
|
||||
public void toggleRounded() {
|
||||
if (hasHintForCurrentPpem()) {
|
||||
return;
|
||||
} // if
|
||||
|
||||
setRounded(!isRounded());
|
||||
}
|
||||
|
||||
public Point2D toPoint2D() {
|
||||
return new Point2D.Double(getX(), getY());
|
||||
}
|
||||
|
||||
public boolean hasHint() {
|
||||
return (getHint().length > 0);
|
||||
}
|
||||
|
||||
public boolean hasHintForCurrentPpem() {
|
||||
return hasHintForPpem(EContour.k_defaultPixelSize);
|
||||
}
|
||||
|
||||
public boolean hasHintForPpem(long a_ppem) {
|
||||
return getHintForPpem(a_ppem) != null;
|
||||
}
|
||||
|
||||
public EPoint getHintIfPossible(long a_ppem) {
|
||||
if (hasHintForPpem(a_ppem)) {
|
||||
return getHintForPpem(a_ppem);
|
||||
} // if
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public EHint getCurrentHint() {
|
||||
return getHintForPpem(EContour.k_defaultPixelSize);
|
||||
}
|
||||
|
||||
public EHint getHintForPpem(long a_ppem) {
|
||||
int i;
|
||||
XHint[] hints = getHint();
|
||||
for (i = 0; i < hints.length; i++) {
|
||||
EHint hint = (EHint) hints[i];
|
||||
if (hint.getPpem() == a_ppem) {
|
||||
return hint;
|
||||
} // if
|
||||
} // for i
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public EHint addHint(int a_ppem) {
|
||||
if (hasHintForPpem(a_ppem)) {
|
||||
return getHintForPpem(a_ppem);
|
||||
} // if
|
||||
|
||||
EHint retval = new EHint(getX() + Engine.getEm() / a_ppem, getY(), a_ppem);
|
||||
addHint(retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
public GlyphObject add() {
|
||||
return getParent().insertPoint(this);
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
getParent().removePoint(this);
|
||||
}
|
||||
|
||||
public PointAggregate getParent() {
|
||||
if (rGetParentRNode() instanceof EControlPoint) {
|
||||
EControlPoint controlPoint = (EControlPoint) rGetParentRNode();
|
||||
return controlPoint.getParent().getParent();
|
||||
}
|
||||
|
||||
if (rGetParentRNode() instanceof PointAggregate) {
|
||||
return (PointAggregate) rGetParentRNode();
|
||||
} // if
|
||||
|
||||
return (PointAggregate) rGetParentRNode();
|
||||
}
|
||||
|
||||
public XContourPoint cloneAt(Point2D a_point) {
|
||||
EContourPoint retval = (EContourPoint) clone();
|
||||
Point2D delta = new Point2D.Double(a_point.getX() - this.getX(), a_point.getY() - this.getY());
|
||||
EObject.movePoint(retval, delta);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/** Moves point by the specified delta. A GlyphObject method.
|
||||
* Delegates the implementation to the host since a point
|
||||
* moves differently depending on the host.
|
||||
* For example the first point hosted by a module invoke would
|
||||
* always be (0, 0) so the invoke position would move instead.
|
||||
*/
|
||||
public void move(Point2D a_delta) {
|
||||
PointAggregate parent = (PointAggregate) rGetParentRNode();
|
||||
parent.movePoint(this, a_delta);
|
||||
}
|
||||
|
||||
public void toggleOnCurve() {
|
||||
if (isControlPoint()) {
|
||||
return;
|
||||
} // if
|
||||
|
||||
if (getParent() instanceof EContour) {
|
||||
EContour contour = (EContour) getParent();
|
||||
if (contour.isCubic()) {
|
||||
toggleCubicControlPoint();
|
||||
return;
|
||||
} // if
|
||||
} // if
|
||||
|
||||
setOn(!isOn());
|
||||
}
|
||||
|
||||
public boolean isControlPoint() {
|
||||
return (getParent() instanceof EContourPoint);
|
||||
}
|
||||
|
||||
private void toggleCubicControlPoint() {
|
||||
if (hasControlPoint1() || hasControlPoint2()) {
|
||||
setControlPoint1(null);
|
||||
setControlPoint2(null);
|
||||
} else {
|
||||
setControlPoint1(new EControlPoint(true, getX() + 100, getY()));
|
||||
setControlPoint2(new EControlPoint(false, getX() - 100, getY()));
|
||||
} // if
|
||||
}
|
||||
|
||||
public boolean hasControlPoint1() {
|
||||
return (getControlPoint1() != null);
|
||||
}
|
||||
|
||||
public boolean hasControlPoint2() {
|
||||
return (getControlPoint2() != null);
|
||||
}
|
||||
|
||||
public void setOn(boolean a_isOnCurve) {
|
||||
if (a_isOnCurve) {
|
||||
setType(k_on);
|
||||
} else {
|
||||
setType(k_off);
|
||||
} // if
|
||||
}
|
||||
|
||||
public boolean hitHint(Rectangle2D a_rect, AffineTransform a_trans) {
|
||||
int ppem = EContour.k_defaultPixelSize;
|
||||
if (!hasHintForPpem(ppem))
|
||||
return false;
|
||||
|
||||
EHint hint = getHintForPpem(ppem);
|
||||
|
||||
Shape hitArea = hint.toShape(a_trans, ppem);
|
||||
if (!hitArea.intersects(a_rect)) {
|
||||
return false;
|
||||
} // if
|
||||
|
||||
EObject.getActives().addActive(hint);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hit(Rectangle2D a_rect, AffineTransform a_trans) {
|
||||
return EObject.hit(this, a_rect, buildOffsetTrans(a_trans));
|
||||
}
|
||||
|
||||
/** Round the value after converting to pixel coordinate system.
|
||||
*/
|
||||
private double round(double a_value, long a_ppem) {
|
||||
double em = Engine.getEm();
|
||||
double funitInGrid = em / a_ppem;
|
||||
|
||||
double pixelValue = a_value / funitInGrid;
|
||||
return funitInGrid * roundSymetric(pixelValue);
|
||||
}
|
||||
|
||||
/** round symetrically about zero.
|
||||
* Math.round(0.5) returns 1. Math.round(-0.5) returns 0,
|
||||
* since it's Math.floor(a_value + -0.5).
|
||||
* -0.5 should round to -1 if it's symetric about zero.
|
||||
* @param a_value number to be rounded.
|
||||
* @return round value.
|
||||
*/
|
||||
private int roundSymetric(double a_value) {
|
||||
if (a_value < 0) {
|
||||
int retval = (int) Math.round(-a_value);
|
||||
return -retval;
|
||||
} else {
|
||||
return (int) Math.round(a_value);
|
||||
} // if-else
|
||||
}
|
||||
|
||||
public void removeControlPoint(EControlPoint a_point) {
|
||||
if (hasControlPoint1() && (getControlPoint1() == a_point)) {
|
||||
setControlPoint1(null);
|
||||
} // if
|
||||
|
||||
if (hasControlPoint2() && (getControlPoint2() == a_point)) {
|
||||
setControlPoint2(null);
|
||||
} // if
|
||||
}
|
||||
/*
|
||||
* $Id: EContourPoint.java,v 1.10 2004/12/27 04:56:02 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.adapter;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class EContourPoint implements EPoint {
|
||||
private boolean isOn;
|
||||
private double x;
|
||||
private double y;
|
||||
private EControlPoint controlPoint1;
|
||||
private EControlPoint controlPoint2;
|
||||
|
||||
public EContourPoint() {
|
||||
super();
|
||||
}
|
||||
|
||||
public EContourPoint(double a_x, double a_y, boolean a_isOn) {
|
||||
x = a_x;
|
||||
y = a_y;
|
||||
|
||||
setOn(a_isOn);
|
||||
}
|
||||
|
||||
public static final int k_defaultPixelSize = 16;
|
||||
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public EControlPoint getControlPoint1() {
|
||||
return controlPoint1;
|
||||
}
|
||||
|
||||
public EControlPoint getControlPoint2() {
|
||||
return controlPoint2;
|
||||
}
|
||||
|
||||
public void setControlPoint1(EControlPoint a_point) {
|
||||
controlPoint1 = a_point;
|
||||
}
|
||||
|
||||
public void setControlPoint2(EControlPoint a_point) {
|
||||
controlPoint2 = a_point;
|
||||
}
|
||||
|
||||
public boolean hasControlPoint1() {
|
||||
return getControlPoint1() != null;
|
||||
}
|
||||
|
||||
public boolean hasControlPoint2() {
|
||||
return getControlPoint2() != null;
|
||||
}
|
||||
|
||||
public boolean isOn() {
|
||||
return isOn;
|
||||
}
|
||||
|
||||
public void setOn(boolean a_isOnCurve) {
|
||||
isOn = a_isOnCurve;
|
||||
}
|
||||
}
|
||||
@@ -1,244 +1,67 @@
|
||||
/*
|
||||
* $Id: EControlPoint.java,v 1.6 2004/12/27 04:56:02 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003-2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.adapter;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Line2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.doubletype.ossa.GlyphColor;
|
||||
import org.doubletype.ossa.xml.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class EControlPoint extends XControlPoint implements GlyphObject, EPoint {
|
||||
private static final String k_true = "true";
|
||||
|
||||
private double m_xOffset = 0;
|
||||
private double m_yOffset = 0;
|
||||
|
||||
public EControlPoint(boolean a_isFirst, double a_x, double a_y) {
|
||||
setSmooth(true);
|
||||
setFirst(a_isFirst);
|
||||
setContourPoint(new EContourPoint(a_x, a_y, false));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public EControlPoint() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param stack
|
||||
*/
|
||||
public EControlPoint(RStack stack) {
|
||||
super(stack);
|
||||
}
|
||||
|
||||
public boolean isSelected() {
|
||||
return EObject.getActives().isSelected(this);
|
||||
}
|
||||
|
||||
/** toggle smooth-ness
|
||||
*/
|
||||
public void convert() {
|
||||
EContourPoint parent = getParent();
|
||||
boolean value = !getSmooth();
|
||||
parent.getControlPoint1().setSmooth(value);
|
||||
parent.getControlPoint2().setSmooth(value);
|
||||
move(new Point2D.Double(0, 0));
|
||||
}
|
||||
|
||||
public boolean isFirst() {
|
||||
return getFirst();
|
||||
}
|
||||
|
||||
public boolean hit(Rectangle2D a_rect, AffineTransform a_trans) {
|
||||
return EObject.hit(this, a_rect, buildOffsetTrans(a_trans));
|
||||
}
|
||||
|
||||
public void setOffset(double a_x, double a_y) {
|
||||
m_xOffset = a_x;
|
||||
m_yOffset = a_y;
|
||||
}
|
||||
|
||||
private AffineTransform buildOffsetTrans(AffineTransform a_trans) {
|
||||
if (m_xOffset == 0 && m_yOffset == 0) {
|
||||
return a_trans;
|
||||
} // if
|
||||
|
||||
AffineTransform retval = (AffineTransform) a_trans.clone();
|
||||
retval.translate(m_xOffset, m_yOffset);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
getParent().removeControlPoint(this);
|
||||
}
|
||||
|
||||
public EContourPoint getParent() {
|
||||
return (EContourPoint) rGetParentRNode();
|
||||
}
|
||||
|
||||
public Shape toShape(AffineTransform a_trans, int a_ppem) {
|
||||
return EObject.toShape(getContourPoint().getPoint2d(), a_trans);
|
||||
}
|
||||
|
||||
public void move(Point2D a_delta) {
|
||||
// if the parent is active, she will move this.
|
||||
if (getParent().isSelected()) {
|
||||
return;
|
||||
} // if
|
||||
|
||||
EObject.movePoint((EContourPoint) getContourPoint(), a_delta);
|
||||
|
||||
if (isSmooth() && hasSibling()) {
|
||||
smoothSibling();
|
||||
} // if
|
||||
}
|
||||
|
||||
public void rotateTo45() {
|
||||
double theta = getTheta() + Math.PI / 8;
|
||||
theta = Math.PI / 4 * Math.floor(theta / (Math.PI / 4));
|
||||
|
||||
rotateToTheta(theta);
|
||||
if (isSmooth() && hasSibling()) {
|
||||
smoothSibling();
|
||||
} // if
|
||||
}
|
||||
|
||||
private void smoothSibling() {
|
||||
getSibling().rotateToTheta(getTheta() + Math.PI);
|
||||
}
|
||||
|
||||
private double getTheta() {
|
||||
EContourPoint parent = getParent();
|
||||
return Math.atan2(getY() - parent.getY(),
|
||||
getX() - parent.getX());
|
||||
}
|
||||
|
||||
private void rotateToTheta(double a_theta) {
|
||||
EContourPoint parent = getParent();
|
||||
double d = parent.toPoint2D().distance(toPoint2D());
|
||||
double x = parent.getX() + Math.cos(a_theta) * d;
|
||||
double y = parent.getY() + Math.sin(a_theta) * d;
|
||||
Point2D delta = new Point2D.Double(x - getX(), y - getY());
|
||||
EObject.movePoint((EContourPoint) getContourPoint(), delta);
|
||||
}
|
||||
|
||||
public Point2D toPoint2D() {
|
||||
EContourPoint point = (EContourPoint) getContourPoint();
|
||||
return point.toPoint2D();
|
||||
}
|
||||
|
||||
public boolean isSmooth() {
|
||||
return getSmooth();
|
||||
}
|
||||
|
||||
public boolean hasSibling() {
|
||||
EContourPoint parent = getParent();
|
||||
if (parent.getControlPoint1() == this) {
|
||||
return parent.hasControlPoint2();
|
||||
} else {
|
||||
return parent.hasControlPoint1();
|
||||
} // if
|
||||
}
|
||||
|
||||
public EControlPoint getSibling() {
|
||||
EContourPoint parent = getParent();
|
||||
if (parent.getControlPoint1() == this) {
|
||||
return (EControlPoint) parent.getControlPoint2();
|
||||
} else {
|
||||
return (EControlPoint) parent.getControlPoint1();
|
||||
} // if
|
||||
}
|
||||
|
||||
public void display(Graphics2D g, AffineTransform a_trans) {
|
||||
AffineTransform trans = buildOffsetTrans(a_trans);
|
||||
displayLine(g, trans);
|
||||
|
||||
Shape rect = toShape(trans, EContour.k_defaultPixelSize);
|
||||
g.setColor(GlyphColor.POINT);
|
||||
if (isSelected()) {
|
||||
g.setColor(GlyphColor.SELECTED);
|
||||
} // if
|
||||
|
||||
g.draw(rect);
|
||||
}
|
||||
|
||||
private void displayLine(Graphics2D g, AffineTransform a_trans) {
|
||||
EContourPoint parent = getParent();
|
||||
Line2D line = new Line2D.Double(parent.getX(),
|
||||
parent.getY(),
|
||||
getX(),
|
||||
getY());
|
||||
AffineTransform oldTrans = g.getTransform();
|
||||
|
||||
g.transform(a_trans);
|
||||
g.setColor(Color.BLACK);
|
||||
g.draw(line);
|
||||
g.setTransform(oldTrans);
|
||||
}
|
||||
|
||||
public EControlPoint transpose(AffineTransform a_trans) {
|
||||
EControlPoint retval = new EControlPoint();
|
||||
EContourPoint point = (EContourPoint) getContourPoint();
|
||||
retval.setContourPoint(point.transpose(a_trans));
|
||||
retval.setSmooth(getSmooth());
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
public double getX() {
|
||||
EContourPoint point = (EContourPoint) getContourPoint();
|
||||
return point.getX();
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
EContourPoint point = (EContourPoint) getContourPoint();
|
||||
return point.getY();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* $Id: EControlPoint.java,v 1.6 2004/12/27 04:56:02 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003-2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.adapter;
|
||||
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.AffineTransform;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class EControlPoint implements EPoint {
|
||||
|
||||
private EContourPoint contourPoint;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public EControlPoint(double x, double y) {
|
||||
contourPoint = new EContourPoint(x, y, false);
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return contourPoint.getX();
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return contourPoint.getY();
|
||||
}
|
||||
|
||||
public EContourPoint getContourPoint() {
|
||||
return contourPoint;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
/*
|
||||
* $Id: EGlyphFactory.java,v 1.3 2004/11/10 01:49:49 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003-2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.adapter;
|
||||
|
||||
import org.doubletype.ossa.xml.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class EGlyphFactory extends DefaultGlyphFactory {
|
||||
public static IGlyphFactory s_factory = null;
|
||||
|
||||
public static IGlyphFactory getFactory() {
|
||||
if (s_factory == null) {
|
||||
s_factory = new EGlyphFactory();
|
||||
} // if
|
||||
|
||||
return s_factory;
|
||||
}
|
||||
|
||||
public EGlyphFactory() {
|
||||
}
|
||||
|
||||
public XModule createXModule() {
|
||||
return new EModuleInvoke();
|
||||
}
|
||||
|
||||
public Class getXModuleClass() {
|
||||
return (EModuleInvoke.class);
|
||||
}
|
||||
|
||||
public XContour createXContour() {
|
||||
return new EContour();
|
||||
}
|
||||
|
||||
public Class getXContourClass() {
|
||||
return (EContour.class);
|
||||
}
|
||||
|
||||
public XInclude createXInclude() {
|
||||
return new EIncludeInvoke();
|
||||
}
|
||||
|
||||
public Class getXIncludeClass() {
|
||||
return (EIncludeInvoke.class);
|
||||
}
|
||||
|
||||
public XHint createXHint() {
|
||||
return new EHint();
|
||||
}
|
||||
|
||||
public Class getXHintClass() {
|
||||
return (EHint.class);
|
||||
}
|
||||
|
||||
public XContourPoint createXContourPoint() {
|
||||
return new EContourPoint();
|
||||
}
|
||||
|
||||
public XContourPoint createXContourPoint(RStack a_stack) {
|
||||
return new EContourPoint(a_stack);
|
||||
}
|
||||
|
||||
public Class getXContourPointClass() {
|
||||
return (EContourPoint.class);
|
||||
}
|
||||
|
||||
public XControlPoint createXControlPoint() {
|
||||
return new EControlPoint();
|
||||
}
|
||||
|
||||
|
||||
public Class getXControlPointClass() {
|
||||
return (EControlPoint.class);
|
||||
}
|
||||
}
|
||||
@@ -1,195 +0,0 @@
|
||||
/*
|
||||
* $Id: EHint.java,v 1.4 2004/12/27 04:56:03 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003-2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.adapter;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.*;
|
||||
|
||||
import org.doubletype.ossa.xml.*;
|
||||
import org.doubletype.ossa.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class EHint extends XHint implements GlyphObject, EPoint {
|
||||
/** offset of this from the global coord.
|
||||
* For contours, it will be 0.
|
||||
* For module invoke, it will be pos.x.
|
||||
* @see EContourPoint
|
||||
*/
|
||||
private double m_xOffset = 0;
|
||||
private double m_yOffset = 0;
|
||||
|
||||
public EHint() {
|
||||
}
|
||||
|
||||
public EHint(double a_x, double a_y, long a_ppem) {
|
||||
XPoint2d point = new XPoint2d();
|
||||
point.setX(a_x);
|
||||
point.setY(a_y);
|
||||
|
||||
setPoint2d(point);
|
||||
setPpem(a_ppem);
|
||||
}
|
||||
|
||||
public void setOffset(double a_x, double a_y) {
|
||||
m_xOffset = a_x;
|
||||
m_yOffset = a_y;
|
||||
}
|
||||
|
||||
private AffineTransform buildOffsetTrans(AffineTransform a_trans) {
|
||||
if (m_xOffset == 0 && m_yOffset == 0) {
|
||||
return a_trans;
|
||||
} // if
|
||||
|
||||
AffineTransform retval = (AffineTransform) a_trans.clone();
|
||||
retval.translate(m_xOffset, m_yOffset);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
public void display(Graphics2D g, AffineTransform a_trans) {
|
||||
AffineTransform trans = buildOffsetTrans(a_trans);
|
||||
|
||||
EContourPoint point = (EContourPoint) rGetParentRNode();
|
||||
|
||||
Shape rect = toShape(trans, EContour.k_defaultPixelSize);
|
||||
Line2D line = new Line2D.Double(point.getX(),
|
||||
point.getY(),
|
||||
getX(),
|
||||
getY());
|
||||
|
||||
AffineTransform oldTrans = g.getTransform();
|
||||
|
||||
g.transform(trans);
|
||||
g.setColor(Color.BLACK);
|
||||
g.draw(line);
|
||||
g.setTransform(oldTrans);
|
||||
|
||||
g.setColor(GlyphColor.HINT);
|
||||
if (isSelected()) {
|
||||
g.setColor(GlyphColor.SELECTED);
|
||||
} // if
|
||||
|
||||
if (point.isOn())
|
||||
g.fill(rect);
|
||||
else
|
||||
g.draw(rect);
|
||||
}
|
||||
|
||||
public boolean isSelected() {
|
||||
return EObject.getActives().isSelected(this);
|
||||
}
|
||||
|
||||
public Shape toShape(AffineTransform a_trans, int a_ppem) {
|
||||
return EObject.toShape(getPoint2d(), a_trans);
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return getPoint2d().getX();
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return getPoint2d().getY();
|
||||
}
|
||||
|
||||
public Point2D toPoint2D() {
|
||||
return new Point2D.Double(getX(), getY());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.doubletype.ossa.adapter.DObject#move(java.awt.geom.Point2D)
|
||||
*/
|
||||
public void move(Point2D a_delta) {
|
||||
EObject.movePoint(getPoint2d(), a_delta);
|
||||
|
||||
double gridWidth = ((double) Engine.getEm()) / getPpem();
|
||||
EContourPoint point = (EContourPoint) rGetParentRNode();
|
||||
|
||||
XPoint2d posHint = getPoint2d();
|
||||
XPoint2d posPoint = point.getPoint2d();
|
||||
double xDelta = posHint.getX() - posPoint.getX();
|
||||
double yDelta = posHint.getY() - posPoint.getY();
|
||||
|
||||
xDelta = correctDelta(xDelta, gridWidth);
|
||||
yDelta = correctDelta(yDelta, gridWidth);
|
||||
|
||||
posHint.setX(posPoint.getX() + xDelta);
|
||||
posHint.setY(posPoint.getY() + yDelta);
|
||||
}
|
||||
|
||||
private double correctDelta(double a_delta, double a_width) {
|
||||
double retval = a_delta;
|
||||
|
||||
if (retval > a_width) {
|
||||
retval = a_width;
|
||||
} // if
|
||||
|
||||
if (retval < -a_width) {
|
||||
retval = -a_width;
|
||||
} // if
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.doubletype.ossa.adapter.DObject#remove()
|
||||
*/
|
||||
public void remove() {
|
||||
getParent().removeHint(this);
|
||||
}
|
||||
|
||||
public EContourPoint getParent() {
|
||||
return (EContourPoint) rGetParentRNode();
|
||||
}
|
||||
|
||||
public PointAggregate getPointHost() {
|
||||
return getParent().getParent();
|
||||
}
|
||||
|
||||
public boolean hit(Rectangle2D a_rect, AffineTransform a_trans) {
|
||||
return EObject.hit(this, a_rect, buildOffsetTrans(a_trans));
|
||||
}
|
||||
|
||||
public EHint createTransform(AffineTransform a_trans) {
|
||||
EHint retval = new EHint();
|
||||
|
||||
retval.setPpem(getPpem());
|
||||
retval.setPoint2d(EObject.createTransform(getPoint2d(), a_trans));
|
||||
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
@@ -1,167 +0,0 @@
|
||||
/*
|
||||
* $Id: EIncludeInvoke.java,v 1.1 2004/09/04 21:54:07 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003-2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.adapter;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.*;
|
||||
import org.doubletype.ossa.xml.*;
|
||||
import org.doubletype.ossa.*;
|
||||
import org.doubletype.ossa.module.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class EIncludeInvoke extends XInclude implements VarStackFrame, GlyphObject {
|
||||
public static EIncludeInvoke create(String a_fileName) {
|
||||
EIncludeInvoke retval = new EIncludeInvoke();
|
||||
retval.setHref(a_fileName);
|
||||
retval.setInvoke(EObject.createInvoke(new Point2D.Double()));
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/** environment with invoke args. */
|
||||
private Hashtable<String,Double> m_augmented = new Hashtable<>();
|
||||
private VarStack m_stack = VarStack.getSingletonInstance();
|
||||
|
||||
public EIncludeInvoke() {
|
||||
}
|
||||
|
||||
public EIncludeInvoke(RStack a_stack) {
|
||||
setup(a_stack);
|
||||
}
|
||||
|
||||
public void display(Graphics2D g, AffineTransform a_trans) {
|
||||
g.setColor(GlyphColor.INCLUDE);
|
||||
if (isSelected()) {
|
||||
g.setColor(GlyphColor.SELECTED);
|
||||
} // if
|
||||
|
||||
g.draw(toShape(a_trans,EContour.k_defaultPixelSize));
|
||||
}
|
||||
|
||||
public boolean isSelected() {
|
||||
return EObject.getActives().isSelected(this);
|
||||
}
|
||||
|
||||
public Shape toShape(AffineTransform a_trans, int a_ppem) {
|
||||
Shape retval;
|
||||
|
||||
ModuleManager manager = ModuleManager.getSingletonInstance();
|
||||
GlyphFile file = manager.getGlyphFile(getHref());
|
||||
|
||||
XPoint2d pos = getInvoke().getInvokePos().getPoint2d();
|
||||
|
||||
AffineTransform trans = new AffineTransform();
|
||||
trans.setTransform(a_trans);
|
||||
trans.translate(pos.getX(), pos.getY());
|
||||
|
||||
m_stack.push(this);
|
||||
retval = file.toShape(trans);
|
||||
m_stack.pop();
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
public GlyphModule getModule() {
|
||||
ModuleManager manager = ModuleManager.getSingletonInstance();
|
||||
return manager.getGlyphFile(getHref());
|
||||
}
|
||||
|
||||
// for var stack frame
|
||||
public boolean hasVariable(String a_name) {
|
||||
return m_augmented.containsKey(a_name);
|
||||
}
|
||||
|
||||
// for var stack frame.
|
||||
public double getValue(String a_name) {
|
||||
Double d = (Double) m_augmented.get(a_name);
|
||||
return d.doubleValue();
|
||||
}
|
||||
|
||||
// for var stack frame.
|
||||
public void beforePush() {
|
||||
getModule().beforePush();
|
||||
loadInvoke(getInvoke());
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
XBody parent = (XBody) rGetParentRNode();
|
||||
parent.removeInclude(this);
|
||||
}
|
||||
|
||||
public void move(Point2D a_delta) {
|
||||
XPoint2d point = getInvoke().getInvokePos().getPoint2d();
|
||||
EObject.movePoint(point, a_delta);
|
||||
}
|
||||
|
||||
/**
|
||||
* loads invoke arguments into this module to build augmented environment.
|
||||
* @param a_invoke
|
||||
*/
|
||||
private void loadInvoke(XInvoke a_invoke) {
|
||||
copyVarsToAug();
|
||||
|
||||
int i;
|
||||
XInvokeVarg [] vargs = a_invoke.getInvokeVarg();
|
||||
for (i = 0; i < vargs.length; i++) {
|
||||
loadVarg(vargs[i]);
|
||||
} // for i
|
||||
}
|
||||
|
||||
private void loadVarg(XInvokeVarg a_varg) {
|
||||
String name = a_varg.getName();
|
||||
String src = a_varg.getSrc();
|
||||
GlyphModule module = getModule();
|
||||
|
||||
if (!module.hasVariable(name)) {
|
||||
return;
|
||||
} // if
|
||||
|
||||
double value = m_stack.get(src);
|
||||
m_augmented.put(name, new Double(value));
|
||||
}
|
||||
|
||||
private void copyVarsToAug() {
|
||||
m_augmented.clear();
|
||||
m_augmented.putAll(getModule().getVars());
|
||||
}
|
||||
|
||||
public boolean hit(Rectangle2D a_rect, AffineTransform a_trans) {
|
||||
return EObject.hit(this, a_rect, a_trans);
|
||||
}
|
||||
}
|
||||
@@ -1,288 +0,0 @@
|
||||
/*
|
||||
* $Id: EModuleInvoke.java,v 1.4 2004/11/08 06:29:51 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003-2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.adapter;
|
||||
|
||||
import org.doubletype.ossa.*;
|
||||
import org.doubletype.ossa.module.*;
|
||||
import org.doubletype.ossa.xml.*;
|
||||
import java.awt.geom.*;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class EModuleInvoke extends XModule implements VarStackFrame, GlyphObject, PointAggregate {
|
||||
public static EModuleInvoke create() {
|
||||
return createAt(new Point2D.Double(0, 254.0));
|
||||
}
|
||||
|
||||
public static EModuleInvoke createAt(Point2D a_point) {
|
||||
EModuleInvoke retval = new EModuleInvoke();
|
||||
|
||||
retval.setName(org.doubletype.ossa.module.Rectangle.class.getName());
|
||||
retval.setInvoke(EObject.createInvoke(a_point));
|
||||
|
||||
double x, y;
|
||||
XContourPoint point;
|
||||
|
||||
x = 0.0;
|
||||
y = 0.0;
|
||||
point = new EContourPoint(x, y, true);
|
||||
retval.addContourPoint(point);
|
||||
|
||||
|
||||
x += 426.0;
|
||||
point = new EContourPoint(x, y, true);
|
||||
retval.addContourPoint(point);
|
||||
|
||||
y -= 254.0;
|
||||
point = new EContourPoint(x, y, true);
|
||||
retval.addContourPoint(point);
|
||||
|
||||
x -= 426.0;
|
||||
point = new EContourPoint(x, y, true);
|
||||
retval.addContourPoint(point);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
/** environment with invoke args. */
|
||||
private Hashtable<String,Double> m_augmented = new Hashtable<>();
|
||||
private VarStack m_stack = VarStack.getSingletonInstance();
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
public EModuleInvoke() {
|
||||
}
|
||||
|
||||
public EModuleInvoke(RStack a_stack) {
|
||||
setup(a_stack);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
public void display(Graphics2D g, AffineTransform a_trans) {
|
||||
if (isSelected()) {
|
||||
g.setColor(GlyphColor.SELECTED);
|
||||
} else {
|
||||
g.setColor(GlyphColor.MODULE);
|
||||
} // if
|
||||
|
||||
g.draw(toShape(a_trans, EContour.k_defaultPixelSize));
|
||||
}
|
||||
|
||||
public boolean isSelected() {
|
||||
return EObject.getActives().isSelected(this);
|
||||
}
|
||||
|
||||
public Shape toShape(AffineTransform a_trans, int a_ppem) {
|
||||
EContour contour = toContour(a_trans);
|
||||
return contour.toShape(new AffineTransform(), a_ppem);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
public EContour toContour(AffineTransform a_trans) {
|
||||
EContour retval;
|
||||
|
||||
GlyphModule module = getModule();
|
||||
|
||||
m_stack.push(this);
|
||||
EContour untransContour = module.toContour(this);
|
||||
m_stack.pop();
|
||||
|
||||
XPoint2d pos = getInvoke().getInvokePos().getPoint2d();
|
||||
AffineTransform trans = (AffineTransform) a_trans.clone();
|
||||
trans.translate(pos.getX(), pos.getY());
|
||||
|
||||
retval = untransContour.transpose(trans);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
public GlyphModule getModule() {
|
||||
return getModuleForName(getName());
|
||||
}
|
||||
|
||||
private GlyphModule getModuleForName(String a_name) {
|
||||
GlyphModule retval = null;
|
||||
|
||||
try {
|
||||
ModuleManager manager = ModuleManager.getSingletonInstance();
|
||||
retval = manager.getModule(a_name);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} // try-catch
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
XBody parent = (XBody) rGetParentRNode();
|
||||
parent.removeModule(this);
|
||||
}
|
||||
|
||||
public void move(Point2D a_delta) {
|
||||
XPoint2d point = getInvoke().getInvokePos().getPoint2d();
|
||||
EObject.movePoint(point, a_delta);
|
||||
}
|
||||
|
||||
// PointAggregate
|
||||
public void removePoint(EContourPoint a_point) {
|
||||
boolean isFirst = (a_point == getContourPoint(0));
|
||||
removeContourPoint(a_point);
|
||||
|
||||
GlyphModule module = getModuleForName(getName());
|
||||
|
||||
if (getContourPoint().length < module.getMinimumPointCount())
|
||||
{
|
||||
remove();
|
||||
return;
|
||||
} // if
|
||||
|
||||
if (!isFirst) {
|
||||
return;
|
||||
} // if
|
||||
|
||||
EContourPoint newFirst = (EContourPoint) getContourPoint(0);
|
||||
Point2D pos = newFirst.toPoint2D();
|
||||
Point2D delta = new Point2D.Double(-pos.getX(), -pos.getY());
|
||||
moveModulePoints(delta);
|
||||
move(pos);
|
||||
}
|
||||
|
||||
public void moveModulePoints(Point2D a_delta) {
|
||||
XContourPoint [] points = getContourPoint();
|
||||
|
||||
int i;
|
||||
for (i = 0; i < points.length; i++) {
|
||||
EContourPoint point = (EContourPoint) points[i];
|
||||
EObject.movePoint(point, a_delta);
|
||||
} // for i
|
||||
}
|
||||
|
||||
// for var stack frame
|
||||
public boolean hasVariable(String a_name) {
|
||||
return m_augmented.containsKey(a_name);
|
||||
}
|
||||
|
||||
// for var stack frame.
|
||||
public double getValue(String a_name) {
|
||||
Double d = (Double) m_augmented.get(a_name);
|
||||
return d.doubleValue();
|
||||
}
|
||||
|
||||
// for var stack frame.
|
||||
public void beforePush() {
|
||||
loadInvoke(getInvoke());
|
||||
}
|
||||
|
||||
/**
|
||||
* loads invoke arguments into this module to build augmented environment.
|
||||
* @param a_invoke
|
||||
*/
|
||||
private void loadInvoke(XInvoke a_invoke) {
|
||||
copyVarsToAug();
|
||||
|
||||
// load varg
|
||||
int i;
|
||||
XInvokeVarg [] vargs = a_invoke.getInvokeVarg();
|
||||
for (i = 0; i < vargs.length; i++) {
|
||||
loadVarg(vargs[i]);
|
||||
} // for i
|
||||
}
|
||||
|
||||
private void loadVarg(XInvokeVarg a_varg) {
|
||||
String name = a_varg.getName();
|
||||
String src = a_varg.getSrc();
|
||||
GlyphModule module = getModule();
|
||||
|
||||
if (!module.hasVariable(name)) {
|
||||
System.out.println(name + " does not exist in "
|
||||
+ module.toString());
|
||||
|
||||
return;
|
||||
} // if
|
||||
|
||||
double value = m_stack.get(src);
|
||||
m_augmented.put(name, new Double(value));
|
||||
}
|
||||
|
||||
private void copyVarsToAug() {
|
||||
m_augmented.clear();
|
||||
m_augmented.putAll(getModule().getVars());
|
||||
}
|
||||
|
||||
public void movePoint(EContourPoint a_point, Point2D a_delta) {
|
||||
EObject.movePoint(a_point, a_delta);
|
||||
|
||||
if (a_point != getContourPoint(0)) {
|
||||
return;
|
||||
} // if
|
||||
|
||||
Point2D negative = new Point2D.Double(-a_delta.getX(), -a_delta.getY());
|
||||
moveModulePoints(negative);
|
||||
move(a_delta);
|
||||
}
|
||||
|
||||
public GlyphObject insertPoint(EContourPoint a_point) {
|
||||
int i;
|
||||
int len = getContourPoint().length;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (getContourPoint(i) == a_point) {
|
||||
break;
|
||||
} // if
|
||||
} // for
|
||||
|
||||
EContourPoint nextPoint;
|
||||
nextPoint = (EContourPoint) getContourPoint((i + 1) % len);
|
||||
|
||||
double x = (a_point.getX() + nextPoint.getX()) / 2;
|
||||
double y = (a_point.getY() + nextPoint.getY()) / 2;
|
||||
|
||||
EContourPoint retval = new EContourPoint(x, y, true);
|
||||
addContourPoint(i + 1, retval);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
public boolean hit(Rectangle2D a_rect, AffineTransform a_trans) {
|
||||
return EObject.hit(this, a_rect, a_trans);
|
||||
}
|
||||
}
|
||||
@@ -1,158 +0,0 @@
|
||||
/*
|
||||
* $Id: EObject.java,v 1.2 2004/11/08 06:29:51 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003-2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.adapter;
|
||||
|
||||
import java.awt.geom.*;
|
||||
import java.awt.*;
|
||||
|
||||
import org.doubletype.ossa.*;
|
||||
import org.doubletype.ossa.truetype.TTPixelSize;
|
||||
import org.doubletype.ossa.xml.*;
|
||||
|
||||
/** Decorator class of xml objects.
|
||||
* @author e.e
|
||||
*/
|
||||
public abstract class EObject {
|
||||
public static final String k_on = "on";
|
||||
public static final String k_off = "off";
|
||||
|
||||
private static ActiveList s_actives = null;
|
||||
|
||||
|
||||
static ActiveList getActives() {
|
||||
if (s_actives == null) {
|
||||
s_actives = ActiveList.getSingletonInstance();
|
||||
} // if
|
||||
|
||||
return s_actives;
|
||||
}
|
||||
|
||||
static Shape toShape(XPoint2d a_point, AffineTransform a_trans) {
|
||||
|
||||
double ratio= EContour.k_defaultPixelSize/TTPixelSize.getEm();
|
||||
|
||||
double x = a_point.getX();
|
||||
double y = a_point.getY();
|
||||
double e = 3 / ratio;
|
||||
Point2D source, dest;
|
||||
source = new Point2D.Double(x, y);
|
||||
dest = new Point2D.Double();
|
||||
dest = a_trans.transform(source, dest);
|
||||
x = dest.getX();
|
||||
y = dest.getY();
|
||||
|
||||
return new Rectangle2D.Double(x - e, y - e, 2 * e + 1, 2 * e + 1);
|
||||
}
|
||||
|
||||
static void movePoint(XPoint2d a_point, Point2D a_delta) {
|
||||
double x = a_point.getX() + a_delta.getX();
|
||||
double y = a_point.getY() + a_delta.getY();
|
||||
|
||||
a_point.setX(x);
|
||||
a_point.setY(y);
|
||||
}
|
||||
|
||||
/**
|
||||
* move the point and hint
|
||||
* @param a_point
|
||||
* @param a_delta
|
||||
*/
|
||||
public static void movePoint(EContourPoint a_point, Point2D a_delta) {
|
||||
movePoint(a_point.getPoint2d(), a_delta);
|
||||
|
||||
XHint [] hints = a_point.getHint();
|
||||
for (int i = 0; i < hints.length; i++) {
|
||||
XHint hint = hints[i];
|
||||
movePoint(hint.getPoint2d(), a_delta);
|
||||
} // for i
|
||||
|
||||
if (a_point.hasControlPoint1()) {
|
||||
EContourPoint point = (EContourPoint) a_point.getControlPoint1().getContourPoint();
|
||||
movePoint(point, a_delta);
|
||||
} // if
|
||||
if (a_point.hasControlPoint2()) {
|
||||
EContourPoint point = (EContourPoint) a_point.getControlPoint2().getContourPoint();
|
||||
movePoint(point, a_delta);
|
||||
} // if
|
||||
}
|
||||
|
||||
public static boolean hit(GlyphObject a_object, Rectangle2D a_rect, AffineTransform a_trans) {
|
||||
int ppem = EContour.k_defaultPixelSize;
|
||||
Shape hitArea = a_object.toShape(a_trans, ppem);
|
||||
if (!hitArea.intersects(a_rect)) {
|
||||
return false;
|
||||
} // if
|
||||
|
||||
EObject.getActives().addActive(a_object);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static XInvoke createInvoke(Point2D a_point) {
|
||||
XInvoke retval = new XInvoke();
|
||||
retval.setInvokePos(createInvokePos(a_point.getX(), a_point.getY()));
|
||||
return retval;
|
||||
}
|
||||
|
||||
public static XPoint2d createTransform(XPoint2d a_point, AffineTransform a_trans) {
|
||||
XPoint2d retval = new XPoint2d();
|
||||
|
||||
double x = a_point.getX();
|
||||
double y = a_point.getY();
|
||||
Point2D source = new Point2D.Double(x, y);
|
||||
Point2D dest = new Point2D.Double();
|
||||
a_trans.transform(source, dest);
|
||||
|
||||
retval.setX(dest.getX());
|
||||
retval.setY(dest.getY());
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
private static XInvokePos createInvokePos(double a_x, double a_y) {
|
||||
XInvokePos retval = new XInvokePos();
|
||||
retval.setPoint2d(createPoint2d(a_x, a_y));
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
private static XPoint2d createPoint2d(double a_x, double a_y) {
|
||||
XPoint2d retval = new XPoint2d();
|
||||
retval.setX(a_x);
|
||||
retval.setY(a_y);
|
||||
return retval;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,361 +0,0 @@
|
||||
/*
|
||||
* $Id: Emulator.java,v 1.6 2004/12/27 04:56:02 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.adapter;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import org.doubletype.ossa.xml.*;
|
||||
|
||||
/** Emulator emulates font engine.
|
||||
* @author e.e
|
||||
*/
|
||||
public class Emulator {
|
||||
private static Emulator s_instance = null;
|
||||
|
||||
// singleton pattern
|
||||
public static Emulator getInstance() {
|
||||
if (s_instance == null) {
|
||||
s_instance = new Emulator();
|
||||
} // if
|
||||
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
private Emulator() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Shape createShape(EContour a_contour, int a_ppem) {
|
||||
if (a_contour.isCubic()) {
|
||||
// return createBezierCurve(a_contour);
|
||||
EContour contour = a_contour.toQuadratic();
|
||||
return createShape(contour, a_ppem);
|
||||
} // if
|
||||
|
||||
return concretePointsToShape(createConcretePoints(
|
||||
createAdjustedPoints(a_contour, a_ppem)));
|
||||
}
|
||||
|
||||
private Shape createBezierCurve(EContour a_contour) {
|
||||
GeneralPath retval = new GeneralPath();
|
||||
XContourPoint [] points = a_contour.getContourPoint();
|
||||
|
||||
if (points.length < 2) {
|
||||
return retval;
|
||||
} // if
|
||||
|
||||
EContourPoint startPoint = (EContourPoint) points[points.length - 1];
|
||||
retval.moveTo((float) startPoint.getX(), (float) startPoint.getY());
|
||||
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
EContourPoint toPoint = (EContourPoint) points[i];
|
||||
EControlPoint controlPoint1 = (EControlPoint) startPoint.getControlPoint2();
|
||||
EControlPoint controlPoint2 = (EControlPoint) toPoint.getControlPoint1();
|
||||
|
||||
// line segment
|
||||
if ((controlPoint1 == null) && (controlPoint2 == null)) {
|
||||
retval.lineTo((float) toPoint.getX(), (float) toPoint.getY());
|
||||
|
||||
} // if
|
||||
|
||||
if ((controlPoint1 != null) && (controlPoint2 == null)) {
|
||||
retval.curveTo((float) controlPoint1.getX(), (float) controlPoint1.getY(),
|
||||
(float) toPoint.getX(), (float) toPoint.getY(),
|
||||
(float) toPoint.getX(), (float) toPoint.getY());
|
||||
} // if
|
||||
|
||||
if ((controlPoint1 == null) && (controlPoint2 != null)) {
|
||||
retval.curveTo((float) startPoint.getX(), (float) startPoint.getY(),
|
||||
(float) controlPoint2.getX(), (float) controlPoint2.getY(),
|
||||
(float) toPoint.getX(), (float) toPoint.getY());
|
||||
} // if
|
||||
|
||||
if ((controlPoint1 != null) && (controlPoint2 != null)) {
|
||||
retval.curveTo((float) controlPoint1.getX(), (float) controlPoint1.getY(),
|
||||
(float) controlPoint2.getX(), (float) controlPoint2.getY(),
|
||||
(float) toPoint.getX(), (float) toPoint.getY());
|
||||
} // if
|
||||
|
||||
startPoint = toPoint;
|
||||
} // for
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
private Shape concretePointsToShape(List a_listOfPoints) {
|
||||
GeneralPath retval = new GeneralPath();
|
||||
EContourPoint p;
|
||||
|
||||
if (a_listOfPoints.size() < 3)
|
||||
return retval;
|
||||
|
||||
p = (EContourPoint) a_listOfPoints.get(0);
|
||||
retval.moveTo((float) p.getX(), (float) p.getY());
|
||||
|
||||
int i = 0;
|
||||
while (i < a_listOfPoints.size() - 1) {
|
||||
i++;
|
||||
EContourPoint nextPoint = (EContourPoint) a_listOfPoints.get(i);
|
||||
|
||||
if (nextPoint.isOn()) {
|
||||
retval.lineTo((float) nextPoint.getX(), (float) nextPoint.getY());
|
||||
} else {
|
||||
EContourPoint controlPoint = nextPoint;
|
||||
i++;
|
||||
EContourPoint toPoint = (EContourPoint) a_listOfPoints.get(i);
|
||||
|
||||
retval.quadTo((float) controlPoint.getX(),
|
||||
(float) controlPoint.getY(),
|
||||
(float) toPoint.getX(), (float) toPoint.getY());
|
||||
} // if-else
|
||||
} // for
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
private List<EContourPoint> createConcretePoints(List a_points) {
|
||||
List<EContourPoint> retval = new ArrayList<>();
|
||||
|
||||
if (a_points.size() < 3)
|
||||
return retval;
|
||||
|
||||
EContourPoint lastPoint = (EContourPoint) a_points.get(a_points.size() - 1);
|
||||
for (int i = 0; i < a_points.size(); i++) {
|
||||
EContourPoint point = (EContourPoint) a_points.get(i);
|
||||
|
||||
if (!point.isOn() && !lastPoint.isOn()) {
|
||||
double xMidpoint = (point.getX() + lastPoint.getX()) / 2;
|
||||
double yMidpoint = (point.getY() + lastPoint.getY()) / 2;
|
||||
retval.add(new EContourPoint(xMidpoint, yMidpoint, true));
|
||||
} // if
|
||||
|
||||
retval.add(new EContourPoint(point.getX(), point.getY(), point.isOn()));
|
||||
lastPoint = point;
|
||||
} // for i
|
||||
|
||||
// all contours should start with on-curve point
|
||||
// move off-curve point to the end if a contour starts with one.
|
||||
EContourPoint point = (EContourPoint) retval.get(0);
|
||||
if (!point.isOn()) {
|
||||
retval.remove(0);
|
||||
retval.add(point);
|
||||
} // if
|
||||
|
||||
point = (EContourPoint) retval.get(0);
|
||||
retval.add(point);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
private List<EContourPoint> createAdjustedPoints(EContour a_contour, int a_ppem) {
|
||||
List<EContourPoint> retval = new ArrayList<>();
|
||||
|
||||
XContourPoint [] points = a_contour.getContourPoint();
|
||||
if (points.length < 3) {
|
||||
return retval;
|
||||
} // if
|
||||
|
||||
boolean isRounded = false;
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
EContourPoint point = (EContourPoint) points[i];
|
||||
point.resetAdjusted();
|
||||
|
||||
if (point.isRounded()) {
|
||||
isRounded = true;
|
||||
point.roundAdjusted(a_ppem);
|
||||
} // if
|
||||
|
||||
retval.add(point);
|
||||
} // for i
|
||||
|
||||
if (isRounded) {
|
||||
interpolate(retval, true);
|
||||
interpolate(retval, false);
|
||||
} // if
|
||||
|
||||
for (int i = 0; i < retval.size(); i++) {
|
||||
EContourPoint point = (EContourPoint) retval.get(i);
|
||||
if (point.hasHintForPpem(a_ppem)) {
|
||||
point.hintAdjusted(a_ppem);
|
||||
} // if
|
||||
} // for i
|
||||
|
||||
return promoteAdjustedToMain(retval);
|
||||
}
|
||||
|
||||
private List<EContourPoint> promoteAdjustedToMain(List<EContourPoint> a_points) {
|
||||
List<EContourPoint> retval = new ArrayList<>();
|
||||
for (int i = 0; i < a_points.size(); i++) {
|
||||
EContourPoint original = (EContourPoint) a_points.get(i);
|
||||
EContourPoint adjusted = new EContourPoint(original.getAdjusted().getX(),
|
||||
original.getAdjusted().getY(),
|
||||
original.isOn());
|
||||
|
||||
retval.add(adjusted);
|
||||
} // for i
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
private void interpolate(List<EContourPoint> a_points, boolean a_isX) {
|
||||
Collection<EContourPoint> sorted = sortPoints(a_points, a_isX);
|
||||
|
||||
Iterator itr = sorted.iterator();
|
||||
|
||||
EContourPoint first = (EContourPoint) itr.next();
|
||||
if (!first.isRounded()) {
|
||||
shiftPoint(first, a_points, a_isX);
|
||||
} // if
|
||||
|
||||
EContourPoint second = (EContourPoint) itr.next();
|
||||
EContourPoint third = null;
|
||||
while (itr.hasNext()) {
|
||||
third = (EContourPoint) itr.next();
|
||||
|
||||
if (!second.isRounded()) {
|
||||
if (first.isRounded()
|
||||
&& third.isRounded()) {
|
||||
interpolate(first, second, third, a_isX);
|
||||
} else {
|
||||
shiftPoint(second, a_points, a_isX);
|
||||
} // if-else
|
||||
} // if
|
||||
|
||||
first = second;
|
||||
second = third;
|
||||
} // while
|
||||
|
||||
EContourPoint last = third;
|
||||
if (!last.isRounded()) {
|
||||
shiftPoint(last, a_points, a_isX);
|
||||
} // if
|
||||
}
|
||||
|
||||
private Collection<EContourPoint> sortPoints(List<EContourPoint> a_points, boolean a_isX) {
|
||||
Map<Double,EContourPoint> sorted = new TreeMap<>();
|
||||
|
||||
for (int i = 0; i < a_points.size(); i++) {
|
||||
EContourPoint original = (EContourPoint) a_points.get(i);
|
||||
Double value = new Double(getPointValue(original, a_isX));
|
||||
|
||||
while (sorted.containsKey(value)) {
|
||||
value = new Double(value.doubleValue() + 0.01);
|
||||
} // while
|
||||
sorted.put(value, original);
|
||||
} // for i
|
||||
|
||||
return sorted.values();
|
||||
}
|
||||
|
||||
private void interpolate(EContourPoint a_first, EContourPoint a_second, EContourPoint a_third, boolean a_isX) {
|
||||
double firstValue = getPointValue(a_first, a_isX);
|
||||
double secondValue = getPointValue(a_second, a_isX);
|
||||
double thirdValue = getPointValue(a_third, a_isX);
|
||||
double adjustedFirst = getAdjustedValue(a_first, a_isX);
|
||||
double adjustedThird = getAdjustedValue(a_third, a_isX);
|
||||
|
||||
double ratio = (secondValue - firstValue) / (thirdValue - firstValue);
|
||||
|
||||
secondValue = adjustedFirst + ratio * (adjustedThird - adjustedFirst);
|
||||
setAdjusted(a_second, secondValue, a_isX);
|
||||
}
|
||||
|
||||
private void shiftPoint(EContourPoint a_point, List<EContourPoint> a_points, boolean a_isX) {
|
||||
EContourPoint closest = closestTouchedPoint(a_point, a_points);
|
||||
if (closest == null) {
|
||||
return;
|
||||
} // if
|
||||
|
||||
double delta = getAdjustedValue(closest, a_isX) - getPointValue(closest, a_isX);
|
||||
double value = getPointValue(a_point, a_isX) + delta;
|
||||
setAdjusted(a_point, value, a_isX);
|
||||
}
|
||||
|
||||
private void setAdjusted(EContourPoint a_point, double a_value, boolean a_isX) {
|
||||
double x = a_point.getX();
|
||||
double y = a_point.getY();
|
||||
|
||||
if (a_isX) {
|
||||
x = a_value;
|
||||
} else {
|
||||
y = a_value;
|
||||
} // if-else
|
||||
|
||||
a_point.setAdjusted(x, y);
|
||||
}
|
||||
|
||||
private double getPointValue(EContourPoint a_point, boolean a_isX) {
|
||||
if (a_isX) {
|
||||
return a_point.getX();
|
||||
} else {
|
||||
return a_point.getY();
|
||||
} // if-else
|
||||
}
|
||||
|
||||
private double getAdjustedValue(EContourPoint a_point, boolean a_isX) {
|
||||
if (a_isX) {
|
||||
return a_point.getAdjusted().getX();
|
||||
} else {
|
||||
return a_point.getAdjusted().getY();
|
||||
} // if-else
|
||||
}
|
||||
|
||||
private EContourPoint closestTouchedPoint(EContourPoint a_point, List<EContourPoint> a_points) {
|
||||
EContourPoint retval = null;
|
||||
double min = Double.MAX_VALUE;
|
||||
for (int i = 0; i < a_points.size(); i++) {
|
||||
EContourPoint target = (EContourPoint) a_points.get(i);
|
||||
if (target == a_point) {
|
||||
continue;
|
||||
} // if
|
||||
|
||||
if (!target.isRounded()) {
|
||||
continue;
|
||||
} // if
|
||||
|
||||
double d = a_point.toPoint2D().distance(target.toPoint2D());
|
||||
if (d < min) {
|
||||
min = d;
|
||||
retval = target;
|
||||
} // if
|
||||
|
||||
} // for i
|
||||
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* $Id: GlyphObject.java,v 1.1 2004/09/04 21:54:06 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003-2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.adapter;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public interface GlyphObject {
|
||||
void move(Point2D a_delta);
|
||||
void remove();
|
||||
Shape toShape(AffineTransform a_trans, int a_ppem);
|
||||
boolean isSelected();
|
||||
void display(Graphics2D g, AffineTransform a_trans);
|
||||
boolean hit(Rectangle2D a_rect, AffineTransform a_trans);
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* $Id: PointAggregate.java,v 1.2 2004/09/18 07:30:44 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.adapter;
|
||||
|
||||
import java.awt.geom.*;
|
||||
import org.doubletype.ossa.xml.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public interface PointAggregate {
|
||||
void removePoint(EContourPoint a_point);
|
||||
void movePoint(EContourPoint a_point, Point2D a_delta);
|
||||
GlyphObject insertPoint(EContourPoint a_point);
|
||||
XContourPoint[] getContourPoint();
|
||||
}
|
||||
@@ -1,188 +1,187 @@
|
||||
/*
|
||||
* $Id: QuadraticSegment.java,v 1.1 2004/12/15 11:54:18 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.adapter;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.doubletype.ossa.xml.XContourPoint;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class QuadraticSegment {
|
||||
public static final int LINE = 0;
|
||||
public static final int CURVE = 1;
|
||||
|
||||
/**
|
||||
* converts quadratic contour into a list of quadratic segments.
|
||||
* @param a_contour
|
||||
* @return
|
||||
*/
|
||||
public static ArrayList<QuadraticSegment> toSegments(EContour a_contour) {
|
||||
ArrayList<QuadraticSegment> retval = new ArrayList<>();
|
||||
|
||||
ArrayList points = toConcreatePoints(a_contour);
|
||||
if (points.size() < 3) {
|
||||
return retval;
|
||||
} // if
|
||||
|
||||
for (int i = 0; i < points.size() - 1; i++) {
|
||||
EContourPoint startPoint = (EContourPoint) points.get(i);
|
||||
EContourPoint nextPoint = (EContourPoint) points.get(i + 1);
|
||||
|
||||
// if this is a line segment
|
||||
if (nextPoint.isOn()) {
|
||||
retval.add(new QuadraticSegment(startPoint, null, nextPoint));
|
||||
} else {
|
||||
EContourPoint offCurvePoint = nextPoint;
|
||||
i++;
|
||||
nextPoint = (EContourPoint) points.get(i + 1);
|
||||
retval.add(new QuadraticSegment(startPoint, offCurvePoint, nextPoint));
|
||||
} // if-else
|
||||
} // for i
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* converts a list of quadratic segments into a quadratic contour.
|
||||
* @param a_segments
|
||||
* @return
|
||||
*/
|
||||
public static EContour toContour(ArrayList<QuadraticSegment> a_segments) {
|
||||
EContour retval = new EContour();
|
||||
retval.setType(EContour.k_quadratic);
|
||||
|
||||
for (QuadraticSegment segment: a_segments) {
|
||||
EContourPoint startPoint = (EContourPoint) segment.m_startPoint.clone();
|
||||
startPoint.setControlPoint1(null);
|
||||
startPoint.setControlPoint2(null);
|
||||
|
||||
if (segment.m_type == LINE) {
|
||||
retval.addContourPoint(startPoint);
|
||||
|
||||
} else {
|
||||
retval.addContourPoint(startPoint);
|
||||
retval.addContourPoint(segment.m_offCurvePoint);
|
||||
}
|
||||
} // for i
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* converts quadratic contour to concreate points by inserting
|
||||
* on-curve point between off-curve points.
|
||||
* @param a_contour
|
||||
* @return
|
||||
*/
|
||||
private static ArrayList<EContourPoint> toConcreatePoints(EContour a_contour) {
|
||||
ArrayList<EContourPoint> retval = new ArrayList<>();
|
||||
|
||||
XContourPoint [] points = a_contour.getContourPoint();
|
||||
if (points.length < 3)
|
||||
return retval;
|
||||
|
||||
EContourPoint fromPoint = (EContourPoint) points[points.length - 1];
|
||||
for (XContourPoint point: points) {
|
||||
EContourPoint toPoint = (EContourPoint) point;
|
||||
if (!toPoint.isOn() && !fromPoint.isOn()) {
|
||||
double xMidpoint = (toPoint.getX() + fromPoint.getX()) / 2;
|
||||
double yMidpoint = (toPoint.getY() + fromPoint.getY()) / 2;
|
||||
retval.add(new EContourPoint(xMidpoint, yMidpoint, true));
|
||||
} // if
|
||||
|
||||
retval.add(toPoint);
|
||||
fromPoint = toPoint;
|
||||
} // for i
|
||||
|
||||
// all contours should start with on-curve point
|
||||
// move off-curve point to the end if a contour starts with one.
|
||||
EContourPoint firstPoint = (EContourPoint) retval.get(0);
|
||||
if (!firstPoint.isOn()) {
|
||||
retval.remove(0);
|
||||
retval.add(firstPoint);
|
||||
} // if
|
||||
|
||||
retval.add(retval.get(0));
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
private EContourPoint m_startPoint;
|
||||
private EContourPoint m_offCurvePoint;
|
||||
private EContourPoint m_endPoint;
|
||||
|
||||
private int m_type = LINE;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public QuadraticSegment(EContourPoint a_startPoint, EContourPoint a_offCurvePoint,
|
||||
EContourPoint a_endPoint) {
|
||||
m_startPoint = a_startPoint;
|
||||
m_offCurvePoint = a_offCurvePoint;
|
||||
m_endPoint = a_endPoint;
|
||||
|
||||
if (m_offCurvePoint != null) {
|
||||
m_type = CURVE;
|
||||
} // if
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert quadratic segment to cubic.
|
||||
* @param a_segment
|
||||
* @return
|
||||
*/
|
||||
public CubicSegment toCubicSegment() {
|
||||
// if the segment is a line
|
||||
if (m_type == LINE) {
|
||||
return new CubicSegment(m_startPoint, m_endPoint);
|
||||
} // if
|
||||
|
||||
double x, y;
|
||||
x = m_startPoint.getX() + 2.0 / 3.0 * (m_offCurvePoint.getX() - m_startPoint.getX());
|
||||
y = m_startPoint.getY() + 2.0 / 3.0 * (m_offCurvePoint.getY() - m_startPoint.getY());
|
||||
EContourPoint controlPoint1 = new EContourPoint(x, y, false);
|
||||
|
||||
x = m_offCurvePoint.getX() + 1.0 / 3.0 * (m_endPoint.getX() - m_offCurvePoint.getX());
|
||||
y = m_offCurvePoint.getY() + 1.0 / 3.0 * (m_endPoint.getY() - m_offCurvePoint.getY());
|
||||
EContourPoint controlPoint2 = new EContourPoint(x, y, false);
|
||||
|
||||
return new CubicSegment(m_startPoint, controlPoint1, controlPoint2, m_endPoint);
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* $Id: QuadraticSegment.java,v 1.1 2004/12/15 11:54:18 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.adapter;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class QuadraticSegment {
|
||||
public static final int LINE = 0;
|
||||
public static final int CURVE = 1;
|
||||
|
||||
/**
|
||||
* converts quadratic contour into a list of quadratic segments.
|
||||
* @param a_contour
|
||||
* @return
|
||||
*/
|
||||
public static ArrayList<QuadraticSegment> toSegments(EContour a_contour) {
|
||||
ArrayList<QuadraticSegment> retval = new ArrayList<>();
|
||||
|
||||
ArrayList points = toConcreatePoints(a_contour);
|
||||
if (points.size() < 3) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
for (int i = 0; i < points.size() - 1; i++) {
|
||||
EContourPoint startPoint = (EContourPoint) points.get(i);
|
||||
EContourPoint nextPoint = (EContourPoint) points.get(i + 1);
|
||||
|
||||
// if this is a line segment
|
||||
if (nextPoint.isOn()) {
|
||||
retval.add(new QuadraticSegment(startPoint, null, nextPoint));
|
||||
} else {
|
||||
EContourPoint offCurvePoint = nextPoint;
|
||||
i++;
|
||||
nextPoint = (EContourPoint) points.get(i + 1);
|
||||
retval.add(new QuadraticSegment(startPoint, offCurvePoint, nextPoint));
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* converts a list of quadratic segments into a quadratic contour.
|
||||
* @param a_segments
|
||||
* @return
|
||||
*/
|
||||
public static EContour toContour(ArrayList<QuadraticSegment> a_segments) {
|
||||
EContour retval = new EContour();
|
||||
retval.setType(EContour.k_quadratic);
|
||||
|
||||
for (QuadraticSegment segment: a_segments) {
|
||||
EContourPoint p = segment.m_startPoint;
|
||||
EContourPoint startPoint = new EContourPoint(p.getX(), p.getY(), p.isOn());
|
||||
startPoint.setControlPoint1(null);
|
||||
startPoint.setControlPoint2(null);
|
||||
|
||||
if (segment.m_type == LINE) {
|
||||
retval.addContourPoint(startPoint);
|
||||
|
||||
} else {
|
||||
retval.addContourPoint(startPoint);
|
||||
retval.addContourPoint(segment.m_offCurvePoint);
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* converts quadratic contour to concreate points by inserting
|
||||
* on-curve point between off-curve points.
|
||||
* @param a_contour
|
||||
* @return
|
||||
*/
|
||||
private static ArrayList<EContourPoint> toConcreatePoints(EContour a_contour) {
|
||||
ArrayList<EContourPoint> retval = new ArrayList<>();
|
||||
|
||||
ArrayList<EContourPoint> points = a_contour.getContourPoints();
|
||||
if (points.size() < 3)
|
||||
return retval;
|
||||
|
||||
EContourPoint fromPoint = (EContourPoint) points.get(points.size() - 1);
|
||||
for (EContourPoint point: points) {
|
||||
EContourPoint toPoint = (EContourPoint) point;
|
||||
if (!toPoint.isOn() && !fromPoint.isOn()) {
|
||||
double xMidpoint = (toPoint.getX() + fromPoint.getX()) / 2;
|
||||
double yMidpoint = (toPoint.getY() + fromPoint.getY()) / 2;
|
||||
retval.add(new EContourPoint(xMidpoint, yMidpoint, true));
|
||||
}
|
||||
|
||||
retval.add(toPoint);
|
||||
fromPoint = toPoint;
|
||||
}
|
||||
|
||||
// all contours should start with on-curve point
|
||||
// move off-curve point to the end if a contour starts with one.
|
||||
EContourPoint firstPoint = (EContourPoint) retval.get(0);
|
||||
if (!firstPoint.isOn()) {
|
||||
retval.remove(0);
|
||||
retval.add(firstPoint);
|
||||
}
|
||||
|
||||
retval.add(retval.get(0));
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
private EContourPoint m_startPoint;
|
||||
private EContourPoint m_offCurvePoint;
|
||||
private EContourPoint m_endPoint;
|
||||
|
||||
private int m_type = LINE;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public QuadraticSegment(EContourPoint a_startPoint, EContourPoint a_offCurvePoint,
|
||||
EContourPoint a_endPoint) {
|
||||
m_startPoint = a_startPoint;
|
||||
m_offCurvePoint = a_offCurvePoint;
|
||||
m_endPoint = a_endPoint;
|
||||
|
||||
if (m_offCurvePoint != null) {
|
||||
m_type = CURVE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert quadratic segment to cubic.
|
||||
* @param a_segment
|
||||
* @return
|
||||
*/
|
||||
public CubicSegment toCubicSegment() {
|
||||
// if the segment is a line
|
||||
if (m_type == LINE) {
|
||||
return new CubicSegment(m_startPoint, m_endPoint);
|
||||
}
|
||||
|
||||
double x, y;
|
||||
x = m_startPoint.getX() + 2.0 / 3.0 * (m_offCurvePoint.getX() - m_startPoint.getX());
|
||||
y = m_startPoint.getY() + 2.0 / 3.0 * (m_offCurvePoint.getY() - m_startPoint.getY());
|
||||
EContourPoint controlPoint1 = new EContourPoint(x, y, false);
|
||||
|
||||
x = m_offCurvePoint.getX() + 1.0 / 3.0 * (m_endPoint.getX() - m_offCurvePoint.getX());
|
||||
y = m_offCurvePoint.getY() + 1.0 / 3.0 * (m_endPoint.getY() - m_offCurvePoint.getY());
|
||||
EContourPoint controlPoint2 = new EContourPoint(x, y, false);
|
||||
|
||||
return new CubicSegment(m_startPoint, controlPoint1, controlPoint2, m_endPoint);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,237 +0,0 @@
|
||||
/*
|
||||
* $Id: GlyphIterator.java,v 1.11 2004/12/27 04:56:03 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003-2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.module;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.doubletype.ossa.xml.*;
|
||||
import org.doubletype.ossa.adapter.*;
|
||||
|
||||
/** Iterates through contours, module invokes, then include invokes.
|
||||
* Used in GlyphFile display
|
||||
* @author e.e
|
||||
*/
|
||||
public class GlyphIterator implements Iterator {
|
||||
protected GlyphFile m_file;
|
||||
private int m_index = 0;
|
||||
protected List<IRNode> m_list = new ArrayList<>();
|
||||
|
||||
public GlyphIterator(GlyphFile a_file) {
|
||||
m_file = a_file;
|
||||
buildList();
|
||||
}
|
||||
|
||||
protected void buildList() {
|
||||
addIncludes();
|
||||
addContours();
|
||||
addModules();
|
||||
|
||||
}
|
||||
|
||||
protected void addContours() {
|
||||
XContour [] contours = m_file.getGlyph().getBody().getContour();
|
||||
for (int i = 0; i < contours.length; i++) {
|
||||
m_list.add(contours[i]);
|
||||
} // for i
|
||||
}
|
||||
|
||||
protected void addControlPoints() {
|
||||
XContour [] contours = m_file.getGlyph().getBody().getContour();
|
||||
for (int i = 0; i < contours.length; i++) {
|
||||
EContour contour = (EContour) contours[i];
|
||||
if (!contour.isCubic()) {
|
||||
continue;
|
||||
} // if
|
||||
|
||||
addControlPoints(contour, 0, 0);
|
||||
} // for i
|
||||
}
|
||||
|
||||
private void addControlPoints(PointAggregate a_object, double a_x, double a_y) {
|
||||
XContourPoint [] points = a_object.getContourPoint();
|
||||
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
EContourPoint point = (EContourPoint) points[i];
|
||||
|
||||
if (!isPointVisible(point)) {
|
||||
continue;
|
||||
} // if
|
||||
|
||||
if (point.hasControlPoint1()) {
|
||||
EControlPoint controlPoint = (EControlPoint) point.getControlPoint1();
|
||||
controlPoint.setOffset(a_x, a_y);
|
||||
m_list.add(controlPoint);
|
||||
} // if
|
||||
|
||||
if (point.hasControlPoint2()) {
|
||||
EControlPoint controlPoint = (EControlPoint) point.getControlPoint2();
|
||||
controlPoint.setOffset(a_x, a_y);
|
||||
m_list.add(controlPoint);
|
||||
} // if
|
||||
} // for j
|
||||
}
|
||||
|
||||
protected void addHints() {
|
||||
XContour [] contours = m_file.getGlyph().getBody().getContour();
|
||||
for (int i = 0; i < contours.length; i++) {
|
||||
addHints((EContour) contours[i], 0, 0);
|
||||
} // for i
|
||||
|
||||
XModule [] modules = m_file.getGlyph().getBody().getModule();
|
||||
for (int i = 0; i < modules.length; i++) {
|
||||
EModuleInvoke module = (EModuleInvoke) modules[i];
|
||||
double x = module.getInvoke().getInvokePos().getPoint2d().getX();
|
||||
double y = module.getInvoke().getInvokePos().getPoint2d().getY();
|
||||
|
||||
addHints(module, x, y);
|
||||
} // for i
|
||||
}
|
||||
|
||||
private void addHints(PointAggregate a_object, double a_x, double a_y) {
|
||||
XContourPoint [] points = a_object.getContourPoint();
|
||||
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
EContourPoint point = (EContourPoint) points[i];
|
||||
|
||||
if (!isPointVisible(point)) {
|
||||
continue;
|
||||
} // if
|
||||
|
||||
if (point.hasHintForCurrentPpem()) {
|
||||
EHint hint = point.getCurrentHint();
|
||||
hint.setOffset(a_x, a_y);
|
||||
m_list.add(hint);
|
||||
} // if
|
||||
|
||||
if (point.hasControlPoint1()) {
|
||||
EContourPoint p = (EContourPoint) point.getControlPoint1().getContourPoint();
|
||||
if (p.hasHintForCurrentPpem()) {
|
||||
EHint hint = p.getCurrentHint();
|
||||
hint.setOffset(a_x, a_y);
|
||||
m_list.add(hint);
|
||||
} // if
|
||||
}
|
||||
|
||||
if (point.hasControlPoint2()) {
|
||||
EContourPoint p = (EContourPoint) point.getControlPoint2().getContourPoint();
|
||||
if (p.hasHintForCurrentPpem()) {
|
||||
EHint hint = p.getCurrentHint();
|
||||
hint.setOffset(a_x, a_y);
|
||||
m_list.add(hint);
|
||||
} // if
|
||||
} // if
|
||||
} // for j
|
||||
}
|
||||
|
||||
private boolean isPointVisible(EContourPoint a_point) {
|
||||
if (m_file.getPointHost() == null) {
|
||||
return true;
|
||||
} // if
|
||||
|
||||
if (m_file.getPointHost() == a_point.getParent()) {
|
||||
return true;
|
||||
} // if
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void addPoints() {
|
||||
XContour [] contours = m_file.getGlyph().getBody().getContour();
|
||||
for (int i = 0; i < contours.length; i++) {
|
||||
addPoints((EContour) contours[i], 0, 0);
|
||||
} // for i
|
||||
|
||||
XModule [] modules = m_file.getGlyph().getBody().getModule();
|
||||
for (int i = 0; i < modules.length; i++) {
|
||||
EModuleInvoke module = (EModuleInvoke) modules[i];
|
||||
double x = module.getInvoke().getInvokePos().getPoint2d().getX();
|
||||
double y = module.getInvoke().getInvokePos().getPoint2d().getY();
|
||||
|
||||
addPoints(module, x, y);
|
||||
} // for i
|
||||
}
|
||||
|
||||
private void addPoints(PointAggregate a_object, double a_x, double a_y) {
|
||||
XContourPoint [] points = a_object.getContourPoint();
|
||||
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
EContourPoint point = (EContourPoint) points[i];
|
||||
|
||||
if (!isPointVisible(point)) {
|
||||
continue;
|
||||
} // if
|
||||
|
||||
point.setNumber(i);
|
||||
point.setOffset(a_x, a_y);
|
||||
m_list.add(point);
|
||||
} // for j
|
||||
}
|
||||
|
||||
protected void addModules() {
|
||||
XModule [] modules = m_file.getGlyph().getBody().getModule();
|
||||
for (int i = 0; i < modules.length; i++) {
|
||||
m_list.add(modules[i]);
|
||||
} // for i
|
||||
}
|
||||
|
||||
protected void addIncludes() {
|
||||
XInclude [] includes = m_file.getGlyph().getBody().getInclude();
|
||||
for (int i = 0; i < includes.length; i++) {
|
||||
m_list.add(includes[i]);
|
||||
} // for i;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.util.Iterator#remove()
|
||||
*/
|
||||
public void remove() {
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.util.Iterator#hasNext()
|
||||
*/
|
||||
public boolean hasNext() {
|
||||
return m_index < m_list.size();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.util.Iterator#next()
|
||||
*/
|
||||
public Object next() {
|
||||
return m_list.get(m_index++);
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
* $Id: GlyphModule.java,v 1.12 2004/09/04 21:54:19 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.module;
|
||||
|
||||
import org.doubletype.ossa.adapter.*;
|
||||
import org.doubletype.ossa.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class GlyphModule implements VarStackFrame {
|
||||
protected VarStack m_stack = VarStack.getSingletonInstance();
|
||||
private Hashtable<String,Double> m_vars = new Hashtable<>();
|
||||
protected ActiveList m_actives = ActiveList.getSingletonInstance();
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
public GlyphModule() {
|
||||
}
|
||||
|
||||
public Hashtable<String,Double> getVars() {
|
||||
return m_vars;
|
||||
}
|
||||
|
||||
// for var stack frame
|
||||
public boolean hasVariable(String a_name) {
|
||||
return m_vars.containsKey(a_name);
|
||||
}
|
||||
|
||||
// for var stack frame.
|
||||
public double getValue(String a_name) {
|
||||
Double d = (Double) m_vars.get(a_name);
|
||||
return d.doubleValue();
|
||||
}
|
||||
|
||||
// for var stack frame.
|
||||
public void beforePush() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Base for generating contours from modules.
|
||||
* @param a_moduleInvoke
|
||||
* @return XContour object which represents the module.
|
||||
*/
|
||||
public EContour toContour(EModuleInvoke a_moduleInvoke) {
|
||||
throw new RuntimeException("Unimplemented contour creation.");
|
||||
}
|
||||
|
||||
public void addVar(String a_name, double a_value) {
|
||||
m_vars.put(a_name, new Double(a_value));
|
||||
}
|
||||
|
||||
public int getMinimumPointCount() {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
@@ -1,192 +0,0 @@
|
||||
/*
|
||||
* $Id: Rectangle.java,v 1.16 2004/09/04 21:54:19 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.module;
|
||||
|
||||
import org.doubletype.ossa.xml.*;
|
||||
import org.doubletype.ossa.adapter.*;
|
||||
|
||||
import java.awt.geom.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*
|
||||
*/
|
||||
public class Rectangle extends GlyphModule {
|
||||
public static final double k_defaultPen = 68.0;
|
||||
public static final double k_defaultWeight = 1.0;
|
||||
public static final String k_weight = "weight";
|
||||
|
||||
public Rectangle() {
|
||||
super();
|
||||
|
||||
addVar(k_weight, k_defaultWeight);
|
||||
}
|
||||
|
||||
public EContour toContour(EModuleInvoke a_moduleInvoke) {
|
||||
int i;
|
||||
EContour retval = new EContour();
|
||||
XContourPoint[] points = a_moduleInvoke.getContourPoint();
|
||||
|
||||
// can't make rectangle with one or zero point
|
||||
if (points.length < 2) {
|
||||
retval.addContourPoint(new EContourPoint(0, 0, true));
|
||||
return retval;
|
||||
} // if
|
||||
|
||||
double pen = m_stack.get(k_weight) * k_defaultPen;
|
||||
boolean steeps[] = new boolean[points.length - 1];
|
||||
double thetas[] = new double[points.length - 1];
|
||||
Point2D outStartPoints[] = new Point2D[points.length - 1];
|
||||
Point2D inStartPoints[] = new Point2D[points.length - 1];
|
||||
Point2D outPoints [] = new Point2D[points.length];
|
||||
Point2D inPoints[] = new Point2D[points.length];
|
||||
|
||||
// treat each segment as a vector (start point and theta)
|
||||
for (i = 0; i < points.length - 1; i++) {
|
||||
EContourPoint start = (EContourPoint) points[i];
|
||||
EContourPoint end = (EContourPoint) points[i + 1];
|
||||
|
||||
// calculate theta of the vector
|
||||
double theta;
|
||||
if (start.toPoint2D().distance(end.toPoint2D()) > 0) {
|
||||
theta = Math.atan2(end.getY() - start.getY(),
|
||||
end.getX() - start.getX());
|
||||
} else {
|
||||
theta = 0.0;
|
||||
} // if
|
||||
|
||||
thetas[i] = theta;
|
||||
outStartPoints[i] = start.toPoint2D();
|
||||
|
||||
// turn the vector 90 degrees clockwise to create the
|
||||
// starting point of the parallel vector (in-vector)
|
||||
inStartPoints[i] = new Point2D.Double(start.getX() + (pen * Math.cos(theta - Math.PI / 2)),
|
||||
start.getY() + (pen * Math.sin(theta - Math.PI / 2)) );
|
||||
} // for i
|
||||
|
||||
for (i = 0; i < points.length; i++) {
|
||||
EContourPoint point = (EContourPoint) points[i];
|
||||
|
||||
if (i == 0) {
|
||||
// dynamically generate the point using vertical line thru p0 and the ideal line.
|
||||
double cuttingTheta;
|
||||
if (isSteep(thetas[i])) {
|
||||
cuttingTheta = 0.0;
|
||||
} else {
|
||||
cuttingTheta = Math.PI / 2;
|
||||
} // if-else
|
||||
|
||||
outPoints[i] = getIntersection(point.toPoint2D(), cuttingTheta,
|
||||
outStartPoints[i], thetas[i]);
|
||||
inPoints[i] = getIntersection(point.toPoint2D(), cuttingTheta,
|
||||
inStartPoints[i], thetas[i]);
|
||||
continue;
|
||||
} else if (i == points.length - 1) {
|
||||
// vertial and ideal.
|
||||
double cuttingTheta;
|
||||
if (isSteep(thetas[i - 1])) {
|
||||
cuttingTheta = 0.0;
|
||||
} else {
|
||||
cuttingTheta = Math.PI / 2;
|
||||
} // if
|
||||
|
||||
outPoints[i] = getIntersection(point.toPoint2D(), cuttingTheta,
|
||||
outStartPoints[i - 1], thetas[i - 1]);
|
||||
inPoints[i] = getIntersection(point.toPoint2D(), cuttingTheta,
|
||||
inStartPoints[i - 1], thetas[i - 1]);
|
||||
|
||||
continue;
|
||||
} // if
|
||||
|
||||
if (thetas[i - 1] != thetas[i]) {
|
||||
outPoints[i] = getIntersection(outStartPoints[i - 1], thetas[i - 1],
|
||||
outStartPoints[i], thetas[i]);
|
||||
inPoints[i] = getIntersection(inStartPoints[i - 1], thetas[i - 1],
|
||||
inStartPoints[i], thetas[i]);
|
||||
} else {
|
||||
outPoints[i] = outStartPoints[i];
|
||||
inPoints[i] = inStartPoints[i];
|
||||
} // if
|
||||
} // for i
|
||||
|
||||
for (i = 0; i < points.length; i++) {
|
||||
EContourPoint point = (EContourPoint) points[i];
|
||||
|
||||
retval.addContourPoint(i, point.cloneAt(outPoints[i]));
|
||||
retval.addContourPoint(i + 1, point.cloneAt(inPoints[i]));
|
||||
} // if
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
private boolean isSteep(double a_theta) {
|
||||
return (a_theta > (Math.PI / 4) && a_theta < (3 * Math.PI / 4))
|
||||
|| (a_theta < (-Math.PI / 4) && a_theta > (-3 * Math.PI / 4));
|
||||
}
|
||||
|
||||
/**
|
||||
* Intersection of two lines line0 and line1, defined by a point and slope.
|
||||
* @param a_p0 a point line0 goes thru.
|
||||
* @param a_theta0 the slope of line0, given in radian.
|
||||
* @param a_p1 a point line1 goes thru.
|
||||
* @param a_theta1 the slope of line1, given in radian.
|
||||
* @return the intersection of line0 and line1, if any; a_p1, otherwise.
|
||||
*/
|
||||
private Point2D getIntersection(Point2D a_p0, double a_theta0,
|
||||
Point2D a_p1, double a_theta1) {
|
||||
Point2D retval = new Point2D.Double();
|
||||
retval.setLocation(a_p1);
|
||||
|
||||
if (a_theta0 == a_theta1)
|
||||
return retval;
|
||||
|
||||
double cos0 = Math.cos(a_theta0);
|
||||
double sin0 = Math.sin(a_theta0);
|
||||
double cos1 = Math.cos(a_theta1);
|
||||
double sin1 = Math.sin(a_theta1);
|
||||
double deltaX = a_p1.getX() - a_p0.getX();
|
||||
double deltaY = a_p1.getY() - a_p0.getY();
|
||||
|
||||
double r1 = (cos0 * deltaY - sin0 * deltaX)
|
||||
/ (sin0 * cos1 - cos0 * sin1);
|
||||
double x = a_p1.getX() + cos1 * r1;
|
||||
double y = a_p1.getY() + sin1 * r1;
|
||||
|
||||
retval.setLocation(x, y);
|
||||
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* $Id: SelectionIterator.java,v 1.2 2004/11/08 06:29:52 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.module;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.doubletype.ossa.adapter.*;
|
||||
import org.doubletype.ossa.xml.IRNode;
|
||||
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class SelectionIterator extends GlyphIterator implements Iterator {
|
||||
|
||||
/**
|
||||
* @param a_file
|
||||
*/
|
||||
public SelectionIterator(GlyphFile a_file) {
|
||||
super(a_file);
|
||||
}
|
||||
|
||||
protected void buildList() {
|
||||
super.buildList();
|
||||
|
||||
List<IRNode> reverseList = new ArrayList<>();
|
||||
for (int i = m_list.size() - 1; i >= 0; i--) {
|
||||
IRNode object = m_list.get(i);
|
||||
|
||||
|
||||
reverseList.add(object);
|
||||
} // for i
|
||||
|
||||
m_list = reverseList;
|
||||
}
|
||||
}
|
||||
@@ -37,8 +37,6 @@ import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import org.doubletype.ossa.*;
|
||||
import org.doubletype.ossa.xml.*;
|
||||
import org.doubletype.ossa.adapter.*;
|
||||
import org.doubletype.ossa.truetype.*;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
@@ -54,23 +52,29 @@ public class TypefaceFile extends GlyphFile {
|
||||
private final double k_defaultBottomSideBearing = 0; // 0 px
|
||||
private final double k_em = 1024;
|
||||
private final int k_defaultAdvanceWidth = 512;
|
||||
private final String k_dotDtyp = ".dtyp";
|
||||
private final String k_dotTtf = ".ttf";
|
||||
|
||||
private File m_dir;
|
||||
private Hashtable<String, Integer> m_nameToIndeces = new Hashtable<>();
|
||||
private File m_ttfFile;
|
||||
private Font m_font = null;
|
||||
private File m_binFolder;
|
||||
private Map<String, GlyphFile> m_glyphFiles = new HashMap<>();
|
||||
|
||||
private List<GlyphFile> m_glyphFiles = new ArrayList<>();
|
||||
private List<String> m_unicodeRanges = new ArrayList<>();
|
||||
private List<String> m_codePages = new ArrayList<>();
|
||||
private String m_fontFamilyName;
|
||||
private String m_subFamily;
|
||||
private String m_version;
|
||||
private Double m_topSideBearing = null;
|
||||
private Double m_ascender = null;
|
||||
private Double m_xHeight = null;
|
||||
private Double m_descender = null;
|
||||
private Double m_bottomSideBearing = null;
|
||||
private String m_name;
|
||||
|
||||
public TypefaceFile(String a_name, File a_dir) throws FileNotFoundException {
|
||||
super(TypefaceFile.class.getResource(s_emptyFileName));
|
||||
super(a_dir);
|
||||
|
||||
m_dir = a_dir;
|
||||
setGlyphTitle(a_name);
|
||||
|
||||
m_fileName = new File(m_dir, a_name + k_dotDtyp);
|
||||
m_name = a_name;
|
||||
initFileName();
|
||||
}
|
||||
|
||||
@@ -78,62 +82,61 @@ public class TypefaceFile extends GlyphFile {
|
||||
super(a_file);
|
||||
|
||||
m_dir = a_file.getParentFile();
|
||||
m_fileName = a_file;
|
||||
m_name = a_file.getName();
|
||||
|
||||
initFileName();
|
||||
}
|
||||
|
||||
private void initFileName() {
|
||||
m_binFolder = new File(m_dir, "bin");
|
||||
if (!m_binFolder.exists()) {
|
||||
m_binFolder.mkdir();
|
||||
} // if
|
||||
|
||||
String fileName = getGlyphTitle() + k_dotTtf;
|
||||
m_ttfFile = new File(m_binFolder, fileName);
|
||||
String fileName = m_name + k_dotTtf;
|
||||
m_ttfFile = new File(m_dir, fileName);
|
||||
}
|
||||
|
||||
public GlyphFile createGlyph(long a_unicode) {
|
||||
String name = Character.getName((int) a_unicode);
|
||||
if (name == null) {
|
||||
name = "NAC_" + Long.toHexString(a_unicode);
|
||||
} // if
|
||||
|
||||
name = name.replace(' ', '_');
|
||||
return new GlyphFile(
|
||||
getGlyphPath(), name, a_unicode);
|
||||
return new GlyphFile(getGlyphPath(), a_unicode);
|
||||
}
|
||||
|
||||
private GlyphFile getGlyphFileByUnicode(long code) {
|
||||
for (GlyphFile glyphFile : m_glyphFiles) {
|
||||
if (glyphFile.getUnicode() == code) {
|
||||
return glyphFile;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean addRequiredGlyphs() {
|
||||
boolean retval = false;
|
||||
|
||||
if (unicodeToFileName(TTUnicodeRange.k_notDef) == null) {
|
||||
GlyphFile glyph = new GlyphFile(getGlyphPath(), "NOTDEF", TTUnicodeRange.k_notDef);
|
||||
if (getGlyphFileByUnicode(TTUnicodeRange.k_notDef) == null) {
|
||||
GlyphFile glyph = new GlyphFile(getGlyphPath(), TTUnicodeRange.k_notDef);
|
||||
glyph.initNotDef(k_defaultAdvanceWidth);
|
||||
addGlyph(0, glyph);
|
||||
retval = true;
|
||||
} // if
|
||||
}
|
||||
|
||||
if (unicodeToFileName(TTUnicodeRange.k_null) == null) {
|
||||
GlyphFile glyph = new GlyphFile(getGlyphPath(), "NULL", TTUnicodeRange.k_null);
|
||||
if (getGlyphFileByUnicode(TTUnicodeRange.k_null) == null) {
|
||||
GlyphFile glyph = new GlyphFile(getGlyphPath(), TTUnicodeRange.k_null);
|
||||
glyph.initNullGlyph();
|
||||
addGlyph(1, glyph);
|
||||
retval = true;
|
||||
} // if
|
||||
}
|
||||
|
||||
if (unicodeToFileName(TTUnicodeRange.k_cr) == null) {
|
||||
GlyphFile glyph = new GlyphFile(getGlyphPath(), "CR", TTUnicodeRange.k_cr);
|
||||
if (getGlyphFileByUnicode(TTUnicodeRange.k_cr) == null) {
|
||||
GlyphFile glyph = new GlyphFile(getGlyphPath(), TTUnicodeRange.k_cr);
|
||||
glyph.initSpace(k_defaultAdvanceWidth);
|
||||
addGlyph(2, glyph);
|
||||
retval = true;
|
||||
} // if
|
||||
}
|
||||
|
||||
if (unicodeToFileName(TTUnicodeRange.k_space) == null) {
|
||||
GlyphFile glyph = new GlyphFile(getGlyphPath(), "SPACE", TTUnicodeRange.k_space);
|
||||
if (getGlyphFileByUnicode(TTUnicodeRange.k_space) == null) {
|
||||
GlyphFile glyph = new GlyphFile(getGlyphPath(), TTUnicodeRange.k_space);
|
||||
glyph.initSpace(k_defaultAdvanceWidth);
|
||||
addGlyph(3, glyph);
|
||||
retval = true;
|
||||
} // if
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -146,175 +149,97 @@ public class TypefaceFile extends GlyphFile {
|
||||
for (long i = range.getStartCode(); i <= range.getEndCode(); i++) {
|
||||
if (i != 0x0020) {
|
||||
addGlyph(createGlyph(i));
|
||||
} // if
|
||||
} // for i
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public File getGlyphPath() {
|
||||
return m_dir;
|
||||
}
|
||||
|
||||
public String unicodeToFileName(long a_unicode) {
|
||||
for (XGlyphFile glyphFile: m_glyph.getBody().getGlyphFile()) {
|
||||
if (glyphFile.getUnicode() == a_unicode) {
|
||||
return glyphFile.getHref();
|
||||
} // if
|
||||
} // for i
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* change glyph's unicode mapping.
|
||||
* @param a_glyphFile
|
||||
* @param a_unicode
|
||||
*/
|
||||
public void setGlyphUnicode(GlyphFile a_glyphFile, long a_unicode) {
|
||||
int i;
|
||||
XGlyphFile [] glyphFiles = m_glyph.getBody().getGlyphFile();
|
||||
for (i = 0; i < glyphFiles.length; i++) {
|
||||
XGlyphFile glyphFile = glyphFiles[i];
|
||||
|
||||
if (glyphFile.getHref().equals(
|
||||
a_glyphFile.getShortFileName())) {
|
||||
continue;
|
||||
} // if
|
||||
|
||||
glyphFile.setUnicode(a_unicode);
|
||||
a_glyphFile.setUnicode(Long.toHexString(a_unicode));
|
||||
|
||||
return;
|
||||
} // for i
|
||||
a_glyphFile.setUnicode(a_unicode);
|
||||
}
|
||||
|
||||
public void addGlyph(GlyphFile a_file) {
|
||||
String shortFileName = a_file.getShortFileName();
|
||||
m_glyphFiles.put(shortFileName, a_file);
|
||||
XGlyphFile xglyphFile = new XGlyphFile();
|
||||
xglyphFile.setHref(shortFileName);
|
||||
xglyphFile.setUnicode(a_file.getUnicodeAsLong());
|
||||
m_glyph.getBody().addGlyphFile(xglyphFile);
|
||||
m_glyphFiles.add(a_file);
|
||||
}
|
||||
|
||||
public void addGlyph(int a_index, GlyphFile a_file) {
|
||||
String shortFileName = a_file.getShortFileName();
|
||||
m_glyphFiles.put(shortFileName, a_file);
|
||||
XGlyphFile xglyphFile = new XGlyphFile();
|
||||
xglyphFile.setHref(shortFileName);
|
||||
xglyphFile.setUnicode(a_file.getUnicodeAsLong());
|
||||
m_glyph.getBody().addGlyphFile(a_index, xglyphFile);
|
||||
}
|
||||
|
||||
public void removeGlyph(String a_fileName) {
|
||||
for (XGlyphFile file: m_glyph.getBody().getGlyphFile()) {
|
||||
if (file.getHref().equals(a_fileName)) {
|
||||
m_glyph.getBody().removeGlyphFile(file);
|
||||
return;
|
||||
} // if
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<String> getChildFileNames() {
|
||||
ArrayList<String> retval = new ArrayList<>();
|
||||
XGlyphFile [] files = m_glyph.getBody().getGlyphFile();
|
||||
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
XGlyphFile file = files[i];
|
||||
retval.add(file.getHref());
|
||||
} // for i
|
||||
|
||||
return retval;
|
||||
m_glyphFiles.add(a_index, a_file);
|
||||
}
|
||||
|
||||
public Object [] getCodePages() {
|
||||
int i;
|
||||
Object [] retval;
|
||||
String [] codePages = m_glyph.getHead().getCodePage();
|
||||
retval = new Object[codePages.length];
|
||||
for (i = 0; i < codePages.length; i++) {
|
||||
retval[i] = codePages[i];
|
||||
} // for i
|
||||
retval = new Object[0];
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
public boolean containsUnicodeRange(String a_unicodeRange) {
|
||||
int i;
|
||||
String [] unicodeRanges = m_glyph.getHead().getUnicodeRange();
|
||||
|
||||
for (i = 0; i < unicodeRanges.length; i++) {
|
||||
if (unicodeRanges[i].equals(a_unicodeRange)) {
|
||||
return true;
|
||||
} // if
|
||||
} // for i
|
||||
|
||||
return false;
|
||||
return m_unicodeRanges.contains(a_unicodeRange);
|
||||
}
|
||||
|
||||
public void addUnicodeRange(String a_unicodeRange) {
|
||||
if (containsUnicodeRange(a_unicodeRange)) {
|
||||
return;
|
||||
} // if
|
||||
}
|
||||
|
||||
m_glyph.getHead().addUnicodeRange(a_unicodeRange);
|
||||
m_unicodeRanges.add(a_unicodeRange);
|
||||
}
|
||||
|
||||
public boolean containsCodePage(String a_codePage) {
|
||||
int i;
|
||||
String [] codePages = m_glyph.getHead().getCodePage();
|
||||
|
||||
for (i = 0; i < codePages.length; i++) {
|
||||
if (codePages[i].equals(a_codePage)) {
|
||||
return true;
|
||||
} // if
|
||||
} // for i
|
||||
|
||||
return false;
|
||||
return m_codePages.contains(a_codePage);
|
||||
}
|
||||
|
||||
public void addCodePage(String a_codePage) {
|
||||
if (containsCodePage(a_codePage)) {
|
||||
return;
|
||||
} // if
|
||||
}
|
||||
|
||||
m_glyph.getHead().addCodePage(a_codePage);
|
||||
m_codePages.add(a_codePage);
|
||||
}
|
||||
|
||||
public void removeCodePage(String a_codePage) {
|
||||
if (!containsCodePage(a_codePage)) {
|
||||
return;
|
||||
} // if
|
||||
}
|
||||
|
||||
m_glyph.getHead().removeCodePage(a_codePage);
|
||||
m_codePages.remove(a_codePage);
|
||||
}
|
||||
|
||||
public void setFontFamilyName(String a_value) {
|
||||
m_glyph.getHead().setFontFamily(a_value);
|
||||
m_fontFamilyName = a_value;
|
||||
}
|
||||
|
||||
public String getFontFamilyName() {
|
||||
return m_glyph.getHead().getFontFamily();
|
||||
return m_fontFamilyName;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
if (m_glyph.getHead().getVersion() == null) {
|
||||
m_glyph.getHead().setVersion("0.1");
|
||||
} // if
|
||||
|
||||
return m_glyph.getHead().getVersion();
|
||||
return m_version == null ? "0.1" : m_version;
|
||||
}
|
||||
|
||||
public void setVersion(String a_value) {
|
||||
m_version = a_value;
|
||||
}
|
||||
|
||||
public void setSubFamily(String a_value) {
|
||||
m_glyph.getHead().setFontSubFamily(a_value);
|
||||
m_subFamily = a_value;
|
||||
}
|
||||
|
||||
public void setDefaultMetrics() {
|
||||
XHead head = m_glyph.getHead();
|
||||
head.setTopSideBearing(k_defaultTopSideBearing);
|
||||
head.setAscender(k_defaultAscender);
|
||||
head.setXHeight(k_defaultXHeight);
|
||||
head.setDescender(k_defaultDescender);
|
||||
head.setBottomSideBearing(k_defaultBottomSideBearing);
|
||||
m_topSideBearing = k_defaultTopSideBearing;
|
||||
m_ascender = k_defaultAscender;
|
||||
m_xHeight = k_defaultXHeight;
|
||||
m_descender = k_defaultDescender;
|
||||
m_bottomSideBearing = k_defaultBottomSideBearing;
|
||||
}
|
||||
|
||||
public double getEm() {
|
||||
@@ -339,78 +264,78 @@ public class TypefaceFile extends GlyphFile {
|
||||
}
|
||||
|
||||
public double getTopSideBearing() {
|
||||
if (!m_glyph.getHead().checkTopSideBearing()) {
|
||||
if (m_topSideBearing == null) {
|
||||
setDefaultMetrics();
|
||||
} // if
|
||||
}
|
||||
|
||||
return m_glyph.getHead().getTopSideBearing();
|
||||
return m_topSideBearing;
|
||||
}
|
||||
|
||||
public double getAscender() {
|
||||
if (!m_glyph.getHead().checkAscender()) {
|
||||
if (m_ascender == null) {
|
||||
setDefaultMetrics();
|
||||
} // if
|
||||
}
|
||||
|
||||
return m_glyph.getHead().getAscender();
|
||||
return m_ascender;
|
||||
}
|
||||
|
||||
public double getXHeight() {
|
||||
if (!m_glyph.getHead().checkXHeight()) {
|
||||
if (m_xHeight == null) {
|
||||
setDefaultMetrics();
|
||||
} // if
|
||||
}
|
||||
|
||||
return m_glyph.getHead().getXHeight();
|
||||
return m_xHeight;
|
||||
}
|
||||
|
||||
public double getDescender() {
|
||||
if (!m_glyph.getHead().checkDescender()) {
|
||||
if (m_descender == null) {
|
||||
setDefaultMetrics();
|
||||
} // if
|
||||
}
|
||||
|
||||
return m_glyph.getHead().getDescender();
|
||||
return m_descender;
|
||||
}
|
||||
|
||||
public double getBottomSideBearing() {
|
||||
if (!m_glyph.getHead().checkBottomSideBearing()) {
|
||||
if (m_bottomSideBearing == null) {
|
||||
setDefaultMetrics();
|
||||
} // if
|
||||
}
|
||||
|
||||
return m_glyph.getHead().getBottomSideBearing();
|
||||
return m_bottomSideBearing;
|
||||
}
|
||||
|
||||
public void setTopSideBearing(double a_value) throws OutOfRangeException {
|
||||
checkBoundary(a_value);
|
||||
m_glyph.getHead().setTopSideBearing(a_value);
|
||||
m_topSideBearing = a_value;
|
||||
}
|
||||
|
||||
private void checkBoundary(double a_value) throws OutOfRangeException {
|
||||
if (a_value > k_em || a_value < 0) {
|
||||
throw new OutOfRangeException(a_value);
|
||||
} // if
|
||||
}
|
||||
}
|
||||
|
||||
public void setAscender(double a_value) throws OutOfRangeException {
|
||||
checkBoundary(a_value);
|
||||
m_glyph.getHead().setAscender(a_value);
|
||||
m_ascender = a_value;
|
||||
}
|
||||
|
||||
public void setXHeight(double a_value) throws OutOfRangeException {
|
||||
checkBoundary(a_value);
|
||||
if (a_value > getAscender()) {
|
||||
throw new OutOfRangeException(a_value);
|
||||
} // if
|
||||
}
|
||||
|
||||
m_glyph.getHead().setXHeight(a_value);
|
||||
m_xHeight = a_value;
|
||||
}
|
||||
|
||||
public void setDescender(double a_value) throws OutOfRangeException {
|
||||
checkBoundary(a_value);
|
||||
m_glyph.getHead().setDescender(a_value);
|
||||
m_descender = a_value;
|
||||
}
|
||||
|
||||
public void setBottomSideBearing(double a_value) throws OutOfRangeException {
|
||||
checkBoundary(a_value);
|
||||
m_glyph.getHead().setBottomSideBearing(a_value);
|
||||
m_bottomSideBearing = a_value;
|
||||
}
|
||||
|
||||
public double getBodyHeight() {
|
||||
@@ -422,27 +347,19 @@ public class TypefaceFile extends GlyphFile {
|
||||
/**
|
||||
* Calls FontFileWriter to produce TrueType font file.
|
||||
*/
|
||||
public void buildTTF(boolean a_isDebug) throws Exception {
|
||||
public void buildTTF() throws Exception {
|
||||
String randomString = UUID.randomUUID().toString().substring(0, 4);
|
||||
|
||||
File tempFile = new File(m_binFolder,
|
||||
getGlyphTitle() + "_" + randomString + k_dotTtf);
|
||||
File tempFile = new File(m_dir,
|
||||
m_name + "_" + randomString + k_dotTtf);
|
||||
File target;
|
||||
String fontFamilyName;
|
||||
|
||||
if (a_isDebug) {
|
||||
target = tempFile;
|
||||
fontFamilyName = getGlyphTitle() + " " + randomString;
|
||||
} else {
|
||||
target = m_ttfFile;
|
||||
fontFamilyName = getFontFamilyName();
|
||||
} // if-else
|
||||
target = m_ttfFile;
|
||||
fontFamilyName = getFontFamilyName();
|
||||
|
||||
target.delete();
|
||||
FontFileWriter writer;
|
||||
ModuleManager.getSingletonInstance().clear();
|
||||
m_stack.clear();
|
||||
m_stack.push(this);
|
||||
try (RandomAccessFile randomAccessFile = new RandomAccessFile(target, "rw")) {
|
||||
writer = new FontFileWriter(randomAccessFile);
|
||||
|
||||
@@ -460,17 +377,14 @@ public class TypefaceFile extends GlyphFile {
|
||||
loadGlyphs(writer);
|
||||
writer.write();
|
||||
}
|
||||
if (!a_isDebug && target.exists()) {
|
||||
if (target.exists()) {
|
||||
copyFile(target, tempFile);
|
||||
} // if
|
||||
}
|
||||
|
||||
FileInputStream in = new FileInputStream(tempFile);
|
||||
m_font = Font.createFont(Font.TRUETYPE_FONT,
|
||||
(InputStream) in);
|
||||
in.close();
|
||||
|
||||
ModuleManager.getSingletonInstance().clear();
|
||||
m_stack.pop(); // pop this
|
||||
}
|
||||
|
||||
private void copyFile(File a_in, File a_out) throws Exception {
|
||||
@@ -491,45 +405,30 @@ public class TypefaceFile extends GlyphFile {
|
||||
}
|
||||
|
||||
private void loadCodePages(FontFileWriter a_writer) {
|
||||
for (String codePageName: m_glyph.getHead().getCodePage()) {
|
||||
for (String codePageName: m_codePages) {
|
||||
TTCodePage codePage = TTCodePage.forName(codePageName);
|
||||
if (codePage == null) {
|
||||
continue;
|
||||
} // if
|
||||
}
|
||||
|
||||
a_writer.setCodeRangeFlag(codePage.getOsTwoFlag());
|
||||
} // for codePageName
|
||||
}
|
||||
|
||||
private void loadUnicodeRanges(FontFileWriter a_writer) {
|
||||
String [] unicodeRanges = m_glyph.getHead().getUnicodeRange();
|
||||
int i;
|
||||
for (i = 0; i < unicodeRanges.length; i++) {
|
||||
if (!TTUnicodeRange.find(unicodeRanges[i])) {
|
||||
for (String unicodeRange : m_unicodeRanges) {
|
||||
if (!TTUnicodeRange.find(unicodeRange)) {
|
||||
continue;
|
||||
} // if
|
||||
}
|
||||
|
||||
a_writer.addUnicodeRange(TTUnicodeRange.getLastFound());
|
||||
} // for i
|
||||
}
|
||||
}
|
||||
|
||||
private void loadGlyphs(FontFileWriter a_writer) throws Exception {
|
||||
m_nameToIndeces.clear();
|
||||
|
||||
for (String fileName: getChildFileNames()) {
|
||||
GlyphFile glyphFile = nameToGlyphFile(fileName);
|
||||
loadGlyph(glyphFile, glyphFile, a_writer);
|
||||
} // for
|
||||
}
|
||||
|
||||
private GlyphFile nameToGlyphFile(String a_fileName) throws FileNotFoundException {
|
||||
if (!m_glyphFiles.containsKey(a_fileName)) {
|
||||
throw new FileNotFoundException(a_fileName);
|
||||
} // if
|
||||
|
||||
GlyphFile retval = m_glyphFiles.get(a_fileName);
|
||||
|
||||
return retval;
|
||||
for (GlyphFile glyphFile : m_glyphFiles) {
|
||||
loadGlyph(glyphFile, a_writer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -538,49 +437,35 @@ public class TypefaceFile extends GlyphFile {
|
||||
* @param a_writer
|
||||
* @throws Exception
|
||||
*/
|
||||
private void loadGlyph(GlyphFile a_glyphFile, VarStackFrame a_frame, FontFileWriter a_writer) throws Exception {
|
||||
if (m_nameToIndeces.containsKey(a_glyphFile.getShortFileName())) {
|
||||
return;
|
||||
} // if
|
||||
|
||||
/*
|
||||
if (a_glyphFile.getUnicodeAsLong() == TTUnicodeRange.k_null) {
|
||||
return;
|
||||
} // if
|
||||
*/
|
||||
|
||||
private void loadGlyph(GlyphFile a_glyphFile, FontFileWriter a_writer) throws Exception {
|
||||
TTGlyph glyph = null;
|
||||
m_stack.push(a_frame);
|
||||
|
||||
if (a_glyphFile.isSimple()) {
|
||||
// glyph will be null if it is empty
|
||||
glyph = a_glyphFile.toSimpleGlyph();
|
||||
} else {
|
||||
glyph = createCompoundGlyph(a_glyphFile, a_writer);
|
||||
} // if
|
||||
|
||||
m_stack.pop();
|
||||
}
|
||||
|
||||
if (glyph == null && a_glyphFile.isWhiteSpace()) {
|
||||
glyph = new TTGlyph();
|
||||
} // if
|
||||
}
|
||||
|
||||
if (glyph == null) {
|
||||
return;
|
||||
} // if
|
||||
}
|
||||
|
||||
int glyphIndex = a_writer.addGlyph(glyph);
|
||||
m_nameToIndeces.put(a_glyphFile.getShortFileName(), glyphIndex);
|
||||
long unicode = a_glyphFile.getUnicodeAsLong();
|
||||
long unicode = a_glyphFile.getUnicode();
|
||||
|
||||
if (unicode != -1 && glyph != null) {
|
||||
if (unicode != -1) {
|
||||
long existingIndex = a_writer.getCharacterMapping(unicode);
|
||||
if (existingIndex != 0) {
|
||||
throw new Exception(Long.toHexString(unicode) + " is mapped already.");
|
||||
} // if
|
||||
}
|
||||
|
||||
a_writer.addCharacterMapping(unicode, glyphIndex);
|
||||
} // if
|
||||
}
|
||||
}
|
||||
|
||||
private TTGlyph createCompoundGlyph(GlyphFile a_glyphFile,
|
||||
@@ -599,25 +484,9 @@ public class TypefaceFile extends GlyphFile {
|
||||
|
||||
locs.add(new Point(0, 0));
|
||||
indeces.add(glyphIndex);
|
||||
} // if
|
||||
}
|
||||
|
||||
XInclude [] includes = a_glyphFile.m_glyph.getBody().getInclude();
|
||||
int i;
|
||||
for (i = 0; i < includes.length; i++) {
|
||||
EIncludeInvoke include = (EIncludeInvoke) includes[i];
|
||||
GlyphFile glyphFile = nameToGlyphFile(include.getHref());
|
||||
|
||||
// load the glyph included in this one
|
||||
loadGlyph(glyphFile, include, a_writer);
|
||||
Integer n = m_nameToIndeces.get(glyphFile.getShortFileName());
|
||||
if (n == null) {
|
||||
continue;
|
||||
} // if
|
||||
|
||||
indeces.add(n);
|
||||
XPoint2d pos = include.getInvoke().getInvokePos().getPoint2d();
|
||||
locs.add(new Point((int) pos.getX(), (int) pos.getY()));
|
||||
} // for i
|
||||
int i = 0;
|
||||
|
||||
int flag = TTGlyph.ARG_1_AND_2_ARE_WORDS
|
||||
| TTGlyph.ARGS_ARE_XY_VALUES
|
||||
@@ -632,14 +501,14 @@ public class TypefaceFile extends GlyphFile {
|
||||
numOfCompositeContours += glyph.getNumOfCompositeContours();
|
||||
if (glyph.getComponentDepth() > componentDepth) {
|
||||
componentDepth = glyph.getComponentDepth();
|
||||
} // if
|
||||
}
|
||||
|
||||
retval.addGlyfIndex(glyfIndex);
|
||||
if (i < indeces.size() - 1) {
|
||||
retval.addFlag(flag | TTGlyph.MORE_COMPONENTS);
|
||||
} else {
|
||||
retval.addFlag(flag);
|
||||
} // if-else
|
||||
}
|
||||
|
||||
Point loc = locs.get(i);
|
||||
retval.addArg1(loc.x);
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
/*
|
||||
* $Id: VarStack.java,v 1.1 2004/04/21 10:54:41 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.module;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class VarStack {
|
||||
private static VarStack s_varstack = null;
|
||||
|
||||
public static VarStack getSingletonInstance() {
|
||||
if (s_varstack == null)
|
||||
s_varstack = new VarStack();
|
||||
|
||||
return s_varstack;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
private ArrayList<VarStackFrame> m_stack = new ArrayList<>();
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
public void push(VarStackFrame a_frame) {
|
||||
a_frame.beforePush();
|
||||
m_stack.add(a_frame);
|
||||
}
|
||||
|
||||
public VarStackFrame pop() {
|
||||
VarStackFrame retval = peek();
|
||||
if (retval == null) {
|
||||
return retval;
|
||||
} // if
|
||||
|
||||
m_stack.remove(retval);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
public VarStackFrame peek() {
|
||||
if (m_stack.size() <= 0) {
|
||||
return null;
|
||||
} // if
|
||||
|
||||
return (VarStackFrame) m_stack.get(m_stack.size() - 1);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
m_stack.clear();
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return m_stack.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* goes through the var stack and returns the variable value
|
||||
* @param a_name name of the variable
|
||||
* @return the value of the variable
|
||||
*/
|
||||
public double get(String a_name) {
|
||||
int i;
|
||||
double retval = 0.0;
|
||||
|
||||
for (i = 0; i < m_stack.size(); i++) {
|
||||
VarStackFrame frame
|
||||
= (VarStackFrame) m_stack.get(m_stack.size() - i - 1);
|
||||
if (!frame.hasVariable(a_name)) {
|
||||
continue;
|
||||
} // if
|
||||
|
||||
return frame.getValue(a_name);
|
||||
} // for i
|
||||
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* $Id: VarStackFrame.java,v 1.1 2004/04/21 10:55:02 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.module;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public interface VarStackFrame {
|
||||
/**
|
||||
* tests if the variable is declared in this module.
|
||||
* @param a_name name of the variable
|
||||
* @return true, if declared; false, otherwise.
|
||||
*/
|
||||
boolean hasVariable(String a_name);
|
||||
double getValue(String a_name);
|
||||
|
||||
/** fired before push by the var stack.
|
||||
*/
|
||||
void beforePush();
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<glyphElement xmlns="http://doubletype.org/ns/glyph/0.0">
|
||||
<head>
|
||||
<title></title>
|
||||
<unicode></unicode>
|
||||
|
||||
<author>Nobody</author>
|
||||
<copyright>2004</copyright>
|
||||
<fontFamily>temp</fontFamily>
|
||||
<fontSubFamily>Regular</fontSubFamily>
|
||||
<license>All rights reserved.</license>
|
||||
|
||||
<global>
|
||||
</global>
|
||||
<local>
|
||||
</local>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</glyphElement>
|
||||
|
||||
@@ -93,7 +93,7 @@ public class CmapWriter extends FontFormatWriter {
|
||||
{
|
||||
m_unicodes.add(unicode);
|
||||
} // for unicode
|
||||
} // for i
|
||||
}
|
||||
|
||||
m_startCodes.add(k_tableEnd);
|
||||
m_endCodes.add(k_tableEnd);
|
||||
@@ -106,7 +106,7 @@ public class CmapWriter extends FontFormatWriter {
|
||||
|
||||
if (m_isIncludeVersion0) {
|
||||
storeVersion0();
|
||||
} // if
|
||||
}
|
||||
storeVersion4();
|
||||
|
||||
reset();
|
||||
@@ -118,19 +118,19 @@ public class CmapWriter extends FontFormatWriter {
|
||||
writeUInt16(TTName.k_macintosh);
|
||||
writeUInt16(TTName.k_macRomanEncode);
|
||||
writeUInt32(size() + 4 + 8);
|
||||
} // if
|
||||
}
|
||||
|
||||
writeUInt16(TTName.k_microsoft);
|
||||
writeUInt16(TTName.k_winUnicodeEncode);
|
||||
int version4Offset = size() + 4;
|
||||
if (m_isIncludeVersion0) {
|
||||
version4Offset += m_version0.length;
|
||||
} // if
|
||||
}
|
||||
writeUInt32(version4Offset);
|
||||
|
||||
if (m_isIncludeVersion0) {
|
||||
m_buffer.write(m_version0);
|
||||
} // if
|
||||
}
|
||||
|
||||
m_buffer.write(m_version4);
|
||||
pad();
|
||||
@@ -139,7 +139,7 @@ public class CmapWriter extends FontFormatWriter {
|
||||
private int getNumOfEncoding() {
|
||||
if (m_isIncludeVersion0) {
|
||||
return 2;
|
||||
} // if
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -164,7 +164,7 @@ public class CmapWriter extends FontFormatWriter {
|
||||
|
||||
if (m_unicode2glyph.containsKey(a_key)) {
|
||||
retval = m_unicode2glyph.get(a_key);
|
||||
} // if
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -208,8 +208,8 @@ public class CmapWriter extends FontFormatWriter {
|
||||
}
|
||||
else {
|
||||
writeUInt8((int) getGlyfIndex((long) i));
|
||||
} // if
|
||||
} // for i
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void writeVersion4() throws IOException {
|
||||
@@ -220,7 +220,7 @@ public class CmapWriter extends FontFormatWriter {
|
||||
for (i = 0; i < segCount; i++) {
|
||||
Long n = (Long) m_endCodes.get(i);
|
||||
writeUInt16(n.intValue());
|
||||
} // for i
|
||||
}
|
||||
|
||||
// reserverdPad
|
||||
writeUInt16(0);
|
||||
@@ -229,13 +229,13 @@ public class CmapWriter extends FontFormatWriter {
|
||||
for (i = 0; i < segCount; i++) {
|
||||
Long n = m_startCodes.get(i);
|
||||
writeUInt16(n.intValue());
|
||||
} // for i
|
||||
}
|
||||
|
||||
// idDelta
|
||||
for (i = 0; i < segCount; i++) {
|
||||
Long n = m_idDeltas.get(i);
|
||||
writeInt16(n.intValue());
|
||||
} // for i
|
||||
}
|
||||
|
||||
// idRangeOffset
|
||||
for (i = 0; i < segCount; i++) {
|
||||
@@ -247,7 +247,7 @@ public class CmapWriter extends FontFormatWriter {
|
||||
for (i = 0; i < m_unicodes.size(); i++) {
|
||||
Long unicode = m_unicodes.get(i);
|
||||
writeUInt16((int) getGlyfIndex(unicode));
|
||||
} // for i
|
||||
}
|
||||
|
||||
byte [] bytes = m_bytes.toByteArray();
|
||||
|
||||
@@ -287,7 +287,7 @@ public class CmapWriter extends FontFormatWriter {
|
||||
writeUInt32(startCharCode.get(i));
|
||||
writeUInt32(endCharCode.get(i));
|
||||
writeUInt32(startGlyphCode.get(i));
|
||||
} // for i
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -269,7 +269,7 @@ public class FontFileWriter extends FontFormatWriter {
|
||||
// padding is always 4 zeros
|
||||
for (int i = 0; i < 4; i++) {
|
||||
writeUInt8(0);
|
||||
} // for i
|
||||
}
|
||||
}
|
||||
|
||||
private int getSearchRange(int a_value) {
|
||||
|
||||
@@ -1,173 +1,173 @@
|
||||
/*
|
||||
* $Id: FontFormatWriter.java,v 1.6 2004/01/28 11:44:08 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.truetype;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class FontFormatWriter {
|
||||
protected DataOutputStream m_buffer;
|
||||
protected ByteArrayOutputStream m_bytes;
|
||||
private int m_offset;
|
||||
|
||||
public FontFormatWriter() {
|
||||
init();
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
m_bytes = new ByteArrayOutputStream();
|
||||
m_buffer = new DataOutputStream(m_bytes);
|
||||
m_offset = 0;
|
||||
}
|
||||
|
||||
public void write() throws IOException {
|
||||
}
|
||||
|
||||
public byte[] toByteArray() {
|
||||
return m_bytes.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Size of buffer in bytes.
|
||||
* @return size of buffer in bytes.
|
||||
*/
|
||||
public int size() {
|
||||
return m_bytes.size();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
m_bytes.reset();
|
||||
}
|
||||
|
||||
protected void writeFixed32(double a_value) throws IOException {
|
||||
final int k_denom = 16384;
|
||||
|
||||
short mantissa = (short) Math.floor(a_value);
|
||||
int fraction = (int) ((a_value - mantissa) * k_denom);
|
||||
if (fraction > k_denom) {
|
||||
fraction = 0;
|
||||
mantissa++;
|
||||
} // if
|
||||
|
||||
m_buffer.writeShort(mantissa);
|
||||
m_buffer.writeShort(fraction);
|
||||
}
|
||||
|
||||
protected void writeUInt16(int a_value) throws IOException {
|
||||
writeInt16((short) (0xffff & a_value));
|
||||
}
|
||||
|
||||
protected void writeInt16(int a_value) throws IOException {
|
||||
m_buffer.writeShort((short) a_value);
|
||||
}
|
||||
|
||||
protected void writeFWord(int a_value) throws IOException {
|
||||
writeInt16(a_value);
|
||||
}
|
||||
|
||||
protected void writeUFWord(int a_value) throws IOException {
|
||||
writeUInt16(a_value);
|
||||
}
|
||||
|
||||
protected void writeUInt32 (long a_value) throws IOException {
|
||||
writeInt32((int) (0xffffffff & a_value));
|
||||
}
|
||||
|
||||
protected void writeInt32(int a_value) throws IOException {
|
||||
m_buffer.writeInt(a_value);
|
||||
}
|
||||
|
||||
protected void writeUInt8(int a_byte) throws IOException {
|
||||
m_buffer.writeByte(a_byte);
|
||||
}
|
||||
|
||||
protected void writeTag(String a_value) throws IOException {
|
||||
String s = a_value + " ";
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 4; i++) {
|
||||
writeUInt8(s.charAt(i));
|
||||
} // for i
|
||||
}
|
||||
|
||||
protected void writeLongDateTime(Date a_date) throws IOException {
|
||||
long sec = a_date.getTime() / 1000;
|
||||
sec += (1970 - 1904) * 365 * 24 * 60 * 60;
|
||||
m_buffer.writeLong(sec);
|
||||
}
|
||||
|
||||
protected String getTag() {
|
||||
throw new RuntimeException("unimplemnted call to getTag");
|
||||
}
|
||||
|
||||
protected long getCheckSum() {
|
||||
long retval = 0;
|
||||
byte [] bytes = toByteArray();
|
||||
|
||||
for (int i = 0; i < bytes.length / 4; i++) {
|
||||
long n = 0;
|
||||
for (int j = 0; j < 4; j++) {
|
||||
n += bytes[4 * i + j] << ((4 - j) * 8);
|
||||
} // for j
|
||||
retval += n;
|
||||
} // for i
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
protected void pad() throws IOException {
|
||||
int align = 4;
|
||||
int numOfPad = align - toByteArray().length % align;
|
||||
if (numOfPad == align)
|
||||
return;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < numOfPad; i++) {
|
||||
writeUInt8(0);
|
||||
} // for i
|
||||
}
|
||||
|
||||
public int getOffset() {
|
||||
return m_offset;
|
||||
}
|
||||
|
||||
public void setOffset(int a_value) {
|
||||
m_offset = a_value;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* $Id: FontFormatWriter.java,v 1.6 2004/01/28 11:44:08 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.truetype;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class FontFormatWriter {
|
||||
protected DataOutputStream m_buffer;
|
||||
protected ByteArrayOutputStream m_bytes;
|
||||
private int m_offset;
|
||||
|
||||
public FontFormatWriter() {
|
||||
init();
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
m_bytes = new ByteArrayOutputStream();
|
||||
m_buffer = new DataOutputStream(m_bytes);
|
||||
m_offset = 0;
|
||||
}
|
||||
|
||||
public void write() throws IOException {
|
||||
}
|
||||
|
||||
public byte[] toByteArray() {
|
||||
return m_bytes.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Size of buffer in bytes.
|
||||
* @return size of buffer in bytes.
|
||||
*/
|
||||
public int size() {
|
||||
return m_bytes.size();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
m_bytes.reset();
|
||||
}
|
||||
|
||||
protected void writeFixed32(double a_value) throws IOException {
|
||||
final int k_denom = 16384;
|
||||
|
||||
short mantissa = (short) Math.floor(a_value);
|
||||
int fraction = (int) ((a_value - mantissa) * k_denom);
|
||||
if (fraction > k_denom) {
|
||||
fraction = 0;
|
||||
mantissa++;
|
||||
}
|
||||
|
||||
m_buffer.writeShort(mantissa);
|
||||
m_buffer.writeShort(fraction);
|
||||
}
|
||||
|
||||
protected void writeUInt16(int a_value) throws IOException {
|
||||
writeInt16((short) (0xffff & a_value));
|
||||
}
|
||||
|
||||
protected void writeInt16(int a_value) throws IOException {
|
||||
m_buffer.writeShort((short) a_value);
|
||||
}
|
||||
|
||||
protected void writeFWord(int a_value) throws IOException {
|
||||
writeInt16(a_value);
|
||||
}
|
||||
|
||||
protected void writeUFWord(int a_value) throws IOException {
|
||||
writeUInt16(a_value);
|
||||
}
|
||||
|
||||
protected void writeUInt32 (long a_value) throws IOException {
|
||||
writeInt32((int) (0xffffffff & a_value));
|
||||
}
|
||||
|
||||
protected void writeInt32(int a_value) throws IOException {
|
||||
m_buffer.writeInt(a_value);
|
||||
}
|
||||
|
||||
protected void writeUInt8(int a_byte) throws IOException {
|
||||
m_buffer.writeByte(a_byte);
|
||||
}
|
||||
|
||||
protected void writeTag(String a_value) throws IOException {
|
||||
String s = a_value + " ";
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 4; i++) {
|
||||
writeUInt8(s.charAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeLongDateTime(Date a_date) throws IOException {
|
||||
long sec = a_date.getTime() / 1000;
|
||||
sec += (1970 - 1904) * 365 * 24 * 60 * 60;
|
||||
m_buffer.writeLong(sec);
|
||||
}
|
||||
|
||||
protected String getTag() {
|
||||
throw new RuntimeException("unimplemnted call to getTag");
|
||||
}
|
||||
|
||||
protected long getCheckSum() {
|
||||
long retval = 0;
|
||||
byte [] bytes = toByteArray();
|
||||
|
||||
for (int i = 0; i < bytes.length / 4; i++) {
|
||||
long n = 0;
|
||||
for (int j = 0; j < 4; j++) {
|
||||
n += bytes[4 * i + j] << ((4 - j) * 8);
|
||||
} // for j
|
||||
retval += n;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
protected void pad() throws IOException {
|
||||
int align = 4;
|
||||
int numOfPad = align - m_bytes.size() % align;
|
||||
if (numOfPad == align)
|
||||
return;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < numOfPad; i++) {
|
||||
writeUInt8(0);
|
||||
}
|
||||
}
|
||||
|
||||
public int getOffset() {
|
||||
return m_offset;
|
||||
}
|
||||
|
||||
public void setOffset(int a_value) {
|
||||
m_offset = a_value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class GlyfWriter extends FontFormatWriter {
|
||||
TTGlyph glyph = m_glyphs.get(i);
|
||||
writeGlyph(glyph);
|
||||
m_hdmx.updatePixelWidth(i, glyph);
|
||||
} // for i
|
||||
}
|
||||
|
||||
m_loca.m_offsets.add(size());
|
||||
}
|
||||
@@ -97,13 +97,13 @@ public class GlyfWriter extends FontFormatWriter {
|
||||
|
||||
if (a_glyph == null) {
|
||||
return;
|
||||
} // if
|
||||
}
|
||||
|
||||
if (a_glyph.isSimple()) {
|
||||
writeSimpleGlyph(a_glyph);
|
||||
} else {
|
||||
writeCompoundGlyph(a_glyph);
|
||||
} // if-else
|
||||
}
|
||||
|
||||
pad();
|
||||
}
|
||||
@@ -115,7 +115,7 @@ public class GlyfWriter extends FontFormatWriter {
|
||||
private void writeSimpleGlyph(TTGlyph a_glyph) throws IOException {
|
||||
if (a_glyph.getNumOfContours() == 0) {
|
||||
return;
|
||||
} // if
|
||||
}
|
||||
|
||||
m_maxp.updateNumOfContours(a_glyph.getNumOfContours());
|
||||
writeInt16(a_glyph.getNumOfContours());
|
||||
@@ -124,7 +124,7 @@ public class GlyfWriter extends FontFormatWriter {
|
||||
int i;
|
||||
for (i = 0; i < a_glyph.getNumOfContours(); i++) {
|
||||
writeUInt16(a_glyph.getEndPoint(i));
|
||||
} // for i
|
||||
}
|
||||
|
||||
int numOfInst = a_glyph.getNumOfInstructions();
|
||||
m_maxp.updateSizeOfInstructions(numOfInst);
|
||||
@@ -132,12 +132,12 @@ public class GlyfWriter extends FontFormatWriter {
|
||||
writeUInt16(numOfInst);
|
||||
for (i = 0; i < numOfInst; i++) {
|
||||
writeUInt8(a_glyph.getInstruction(i));
|
||||
} // for i
|
||||
}
|
||||
|
||||
for (i = 0; i < a_glyph.getNumOfFlags(); i++) {
|
||||
int flag = a_glyph.getFlag(i);
|
||||
writeUInt8(flag);
|
||||
} // for i
|
||||
}
|
||||
|
||||
// update num of points
|
||||
m_maxp.updateNumOfPoints(a_glyph.getNumOfPoints());
|
||||
@@ -148,7 +148,7 @@ public class GlyfWriter extends FontFormatWriter {
|
||||
|
||||
writeInt16(point.x - lastX);
|
||||
lastX = point.x;
|
||||
} // for i
|
||||
}
|
||||
|
||||
int lastY = 0;
|
||||
for (i = 0; i < a_glyph.getNumOfPoints(); i++) {
|
||||
@@ -156,7 +156,7 @@ public class GlyfWriter extends FontFormatWriter {
|
||||
|
||||
writeInt16(point.y - lastY);
|
||||
lastY = point.y;
|
||||
} // for i
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,7 +181,7 @@ public class GlyfWriter extends FontFormatWriter {
|
||||
writeUInt16(a_glyph.getGlyfIndex(i));
|
||||
writeInt16(a_glyph.getArg1(i));
|
||||
writeInt16(a_glyph.getArg2(i));
|
||||
} // for i
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,117 +1,117 @@
|
||||
/*
|
||||
* $Copyright: copyright (c) 2003-2008, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
|
||||
package org.doubletype.ossa.truetype;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* HtmxWriter depends on GlyfWriter.
|
||||
*
|
||||
* @author e.e
|
||||
*/
|
||||
public class HdmxWriter extends FontFormatWriter {
|
||||
static public int getNumOfPixelSizes() {
|
||||
return TTPixelSize.getList().size();
|
||||
}
|
||||
|
||||
static public ArrayList<TTPixelSize> getPixelSizes() {
|
||||
return TTPixelSize.getList();
|
||||
}
|
||||
|
||||
private int m_numGlyphs = 98; // set by GlyfWriter
|
||||
|
||||
public HdmxWriter() {
|
||||
super();
|
||||
}
|
||||
|
||||
/** set the number of glyphs in the font */
|
||||
public void setNumGlyphs(int a_value) {
|
||||
m_numGlyphs = a_value;
|
||||
|
||||
for (TTPixelSize pixelSize: getPixelSizes()) {
|
||||
pixelSize.setPixelWidthsSize(a_value);
|
||||
} // for pixelSize
|
||||
}
|
||||
|
||||
public void updatePixelWidth(int a_glyphIndex, TTGlyph a_glyph) {
|
||||
double advanceWidth = a_glyph.getAdvanceWidth();
|
||||
double em = TTPixelSize.getEm();
|
||||
|
||||
for (TTPixelSize pixelSize: TTPixelSize.getList()) {
|
||||
int width = (int) Math.round(((double) pixelSize.getPixel() * advanceWidth) / em);
|
||||
pixelSize.setPixelWidth(a_glyphIndex, width);
|
||||
} // pixelSize
|
||||
}
|
||||
|
||||
/**
|
||||
* writes htmx record.
|
||||
* The size of a device record is calculated to align it to 32bit boundary.
|
||||
*/
|
||||
public void write() throws IOException {
|
||||
int numOfPads = 4 - ((m_numGlyphs + 2) % 4);
|
||||
if (numOfPads == 4) {
|
||||
numOfPads = 0;
|
||||
} // if
|
||||
int size = m_numGlyphs + 2 + numOfPads; // 2 comes from the ppem and max
|
||||
|
||||
// format version number
|
||||
writeInt16(0);
|
||||
|
||||
// number of device records
|
||||
writeInt16(getNumOfPixelSizes());
|
||||
//System.out.printf("num of pixel sizes %d\n", getNumOfPixelSizes());
|
||||
// size of device record
|
||||
writeInt32(size);
|
||||
//System.out.printf("num of glyphs %d\n", m_numGlyphs);
|
||||
for (TTPixelSize pixelSize: getPixelSizes()) {
|
||||
writeUInt8(pixelSize.getPixel());
|
||||
writeUInt8(pixelSize.getMaxPixelWidth());
|
||||
for (int pixelWidth: pixelSize.getPixelWidths()) {
|
||||
writeUInt8(pixelWidth);
|
||||
} // for pixelWidth
|
||||
|
||||
for (int j = 0; j < numOfPads; j++) {
|
||||
writeUInt8(0);
|
||||
} // for j
|
||||
} // for pixelSize
|
||||
|
||||
pad();
|
||||
}
|
||||
|
||||
protected String getTag() {
|
||||
return "hdmx";
|
||||
}
|
||||
}
|
||||
/*
|
||||
* $Copyright: copyright (c) 2003-2008, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
|
||||
package org.doubletype.ossa.truetype;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* HtmxWriter depends on GlyfWriter.
|
||||
*
|
||||
* @author e.e
|
||||
*/
|
||||
public class HdmxWriter extends FontFormatWriter {
|
||||
static public int getNumOfPixelSizes() {
|
||||
return TTPixelSize.getList().size();
|
||||
}
|
||||
|
||||
static public ArrayList<TTPixelSize> getPixelSizes() {
|
||||
return TTPixelSize.getList();
|
||||
}
|
||||
|
||||
private int m_numGlyphs = 98; // set by GlyfWriter
|
||||
|
||||
public HdmxWriter() {
|
||||
super();
|
||||
}
|
||||
|
||||
/** set the number of glyphs in the font */
|
||||
public void setNumGlyphs(int a_value) {
|
||||
m_numGlyphs = a_value;
|
||||
|
||||
for (TTPixelSize pixelSize: getPixelSizes()) {
|
||||
pixelSize.setPixelWidthsSize(a_value);
|
||||
} // for pixelSize
|
||||
}
|
||||
|
||||
public void updatePixelWidth(int a_glyphIndex, TTGlyph a_glyph) {
|
||||
double advanceWidth = a_glyph.getAdvanceWidth();
|
||||
double em = TTPixelSize.getEm();
|
||||
|
||||
for (TTPixelSize pixelSize: TTPixelSize.getList()) {
|
||||
int width = (int) Math.round(((double) pixelSize.getPixel() * advanceWidth) / em);
|
||||
pixelSize.setPixelWidth(a_glyphIndex, width);
|
||||
} // pixelSize
|
||||
}
|
||||
|
||||
/**
|
||||
* writes htmx record.
|
||||
* The size of a device record is calculated to align it to 32bit boundary.
|
||||
*/
|
||||
public void write() throws IOException {
|
||||
int numOfPads = 4 - ((m_numGlyphs + 2) % 4);
|
||||
if (numOfPads == 4) {
|
||||
numOfPads = 0;
|
||||
}
|
||||
int size = m_numGlyphs + 2 + numOfPads; // 2 comes from the ppem and max
|
||||
|
||||
// format version number
|
||||
writeInt16(0);
|
||||
|
||||
// number of device records
|
||||
writeInt16(getNumOfPixelSizes());
|
||||
//System.out.printf("num of pixel sizes %d\n", getNumOfPixelSizes());
|
||||
// size of device record
|
||||
writeInt32(size);
|
||||
//System.out.printf("num of glyphs %d\n", m_numGlyphs);
|
||||
for (TTPixelSize pixelSize: getPixelSizes()) {
|
||||
writeUInt8(pixelSize.getPixel());
|
||||
writeUInt8(pixelSize.getMaxPixelWidth());
|
||||
for (int pixelWidth: pixelSize.getPixelWidths()) {
|
||||
writeUInt8(pixelWidth);
|
||||
} // for pixelWidth
|
||||
|
||||
for (int j = 0; j < numOfPads; j++) {
|
||||
writeUInt8(0);
|
||||
} // for j
|
||||
} // for pixelSize
|
||||
|
||||
pad();
|
||||
}
|
||||
|
||||
protected String getTag() {
|
||||
return "hdmx";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,156 +1,156 @@
|
||||
/*
|
||||
* $Id: HeadWriter.java,v 1.7 2004/09/26 09:15:48 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
|
||||
package org.doubletype.ossa.truetype;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class HeadWriter extends FontFormatWriter {
|
||||
static public final int k_yZeroIsBaseLine = 0x1; // bit 0
|
||||
static public final int k_xLeftMostBlackIsLsb = 0x2; // bit 1
|
||||
static public final int k_scaledPointDiffer = 0x4; // bit 2
|
||||
static public final int k_useIntegerScaling = 0x8; // bit 3
|
||||
|
||||
// used by microsoft
|
||||
static public final int k_scaleLinear = 0x10;
|
||||
|
||||
// for vertical fonts
|
||||
static public final int k_xZeroIsBaseLine = 0x20;
|
||||
// 0x40
|
||||
static public final int k_linguisticRendering = 0x80;
|
||||
static public final int k_defaultMetamorphosis = 0x100;
|
||||
static public final int k_rightToLeft = 0x200;
|
||||
static public final int k_indicRearrangement = 0x400;
|
||||
|
||||
|
||||
private final long k_magicNumber = 0x5f0f3cf5;
|
||||
|
||||
private long m_checkSumAdjustment = 0;
|
||||
private Point m_min = new Point(0, 0);
|
||||
private Point m_max = new Point(0, 0);
|
||||
|
||||
public HeadWriter() {
|
||||
super();
|
||||
}
|
||||
|
||||
void setCheckSumAdjustment(long a_value) {
|
||||
m_checkSumAdjustment = a_value;
|
||||
}
|
||||
|
||||
public Point getMin() {
|
||||
return m_min;
|
||||
}
|
||||
|
||||
public Point getMax() {
|
||||
return m_max;
|
||||
}
|
||||
|
||||
public void updateMin(Point a_value) {
|
||||
if (a_value.x < m_min.x) {
|
||||
m_min.x = a_value.x;
|
||||
} // if
|
||||
|
||||
if (a_value.y < m_min.y) {
|
||||
m_min.y = a_value.y;
|
||||
} // if
|
||||
}
|
||||
|
||||
public void updateMax(Point a_value) {
|
||||
if (a_value.x > m_max.x) {
|
||||
m_max.x = a_value.x;
|
||||
} // if
|
||||
|
||||
if (a_value.y > m_max.y) {
|
||||
m_max.y = a_value.y;
|
||||
} // if
|
||||
}
|
||||
|
||||
public void write() throws IOException {
|
||||
// table version number
|
||||
writeFixed32(1.0);
|
||||
|
||||
// fontRevision
|
||||
writeFixed32(1.0);
|
||||
|
||||
writeUInt32(m_checkSumAdjustment);
|
||||
writeUInt32(k_magicNumber);
|
||||
|
||||
// LSB is the distance from 0, 0 to the left of the glyph bounds.
|
||||
// flags
|
||||
writeUInt16(k_yZeroIsBaseLine
|
||||
| k_xLeftMostBlackIsLsb
|
||||
| k_scaledPointDiffer);;
|
||||
|
||||
// unitsPerEm
|
||||
writeUInt16(1024);
|
||||
|
||||
// created, modified
|
||||
writeLongDateTime(new Date());
|
||||
writeLongDateTime(new Date());
|
||||
|
||||
writeFWord(m_min.x);
|
||||
writeFWord(m_min.y);
|
||||
writeFWord(m_max.x);
|
||||
writeFWord(m_max.y);
|
||||
|
||||
// macStyle
|
||||
writeUInt16(0);
|
||||
|
||||
// lowestRecPPEM
|
||||
writeUInt16(11);
|
||||
|
||||
// font direction hint
|
||||
// 2, for strongly left to right
|
||||
// but also contains neutrals
|
||||
writeInt16(2);
|
||||
|
||||
// indexToLocFormat. 1, for long
|
||||
writeInt16(1);
|
||||
|
||||
// glyfDataFormat
|
||||
writeInt16(0);
|
||||
pad();
|
||||
}
|
||||
|
||||
protected String getTag() {
|
||||
return "head";
|
||||
}
|
||||
}
|
||||
/*
|
||||
* $Id: HeadWriter.java,v 1.7 2004/09/26 09:15:48 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
|
||||
package org.doubletype.ossa.truetype;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class HeadWriter extends FontFormatWriter {
|
||||
static public final int k_yZeroIsBaseLine = 0x1; // bit 0
|
||||
static public final int k_xLeftMostBlackIsLsb = 0x2; // bit 1
|
||||
static public final int k_scaledPointDiffer = 0x4; // bit 2
|
||||
static public final int k_useIntegerScaling = 0x8; // bit 3
|
||||
|
||||
// used by microsoft
|
||||
static public final int k_scaleLinear = 0x10;
|
||||
|
||||
// for vertical fonts
|
||||
static public final int k_xZeroIsBaseLine = 0x20;
|
||||
// 0x40
|
||||
static public final int k_linguisticRendering = 0x80;
|
||||
static public final int k_defaultMetamorphosis = 0x100;
|
||||
static public final int k_rightToLeft = 0x200;
|
||||
static public final int k_indicRearrangement = 0x400;
|
||||
|
||||
|
||||
private final long k_magicNumber = 0x5f0f3cf5;
|
||||
|
||||
private long m_checkSumAdjustment = 0;
|
||||
private Point m_min = new Point(0, 0);
|
||||
private Point m_max = new Point(0, 0);
|
||||
|
||||
public HeadWriter() {
|
||||
super();
|
||||
}
|
||||
|
||||
void setCheckSumAdjustment(long a_value) {
|
||||
m_checkSumAdjustment = a_value;
|
||||
}
|
||||
|
||||
public Point getMin() {
|
||||
return m_min;
|
||||
}
|
||||
|
||||
public Point getMax() {
|
||||
return m_max;
|
||||
}
|
||||
|
||||
public void updateMin(Point a_value) {
|
||||
if (a_value.x < m_min.x) {
|
||||
m_min.x = a_value.x;
|
||||
}
|
||||
|
||||
if (a_value.y < m_min.y) {
|
||||
m_min.y = a_value.y;
|
||||
}
|
||||
}
|
||||
|
||||
public void updateMax(Point a_value) {
|
||||
if (a_value.x > m_max.x) {
|
||||
m_max.x = a_value.x;
|
||||
}
|
||||
|
||||
if (a_value.y > m_max.y) {
|
||||
m_max.y = a_value.y;
|
||||
}
|
||||
}
|
||||
|
||||
public void write() throws IOException {
|
||||
// table version number
|
||||
writeFixed32(1.0);
|
||||
|
||||
// fontRevision
|
||||
writeFixed32(1.0);
|
||||
|
||||
writeUInt32(m_checkSumAdjustment);
|
||||
writeUInt32(k_magicNumber);
|
||||
|
||||
// LSB is the distance from 0, 0 to the left of the glyph bounds.
|
||||
// flags
|
||||
writeUInt16(k_yZeroIsBaseLine
|
||||
| k_xLeftMostBlackIsLsb
|
||||
| k_scaledPointDiffer);;
|
||||
|
||||
// unitsPerEm
|
||||
writeUInt16(1024);
|
||||
|
||||
// created, modified
|
||||
writeLongDateTime(new Date());
|
||||
writeLongDateTime(new Date());
|
||||
|
||||
writeFWord(m_min.x);
|
||||
writeFWord(m_min.y);
|
||||
writeFWord(m_max.x);
|
||||
writeFWord(m_max.y);
|
||||
|
||||
// macStyle
|
||||
writeUInt16(0);
|
||||
|
||||
// lowestRecPPEM
|
||||
writeUInt16(11);
|
||||
|
||||
// font direction hint
|
||||
// 2, for strongly left to right
|
||||
// but also contains neutrals
|
||||
writeInt16(2);
|
||||
|
||||
// indexToLocFormat. 1, for long
|
||||
writeInt16(1);
|
||||
|
||||
// glyfDataFormat
|
||||
writeInt16(0);
|
||||
pad();
|
||||
}
|
||||
|
||||
protected String getTag() {
|
||||
return "head";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,108 +1,108 @@
|
||||
/*
|
||||
* $Id: HheaWriter.java,v 1.5 2004/09/26 09:15:48 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
|
||||
package org.doubletype.ossa.truetype;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* HheaWriter depends on HtmxWriter.
|
||||
* @author e.e
|
||||
*/
|
||||
public class HheaWriter extends FontFormatWriter {
|
||||
private GlyfWriter m_glyf;
|
||||
private HeadWriter m_head;
|
||||
|
||||
private int m_lineGap = 0;
|
||||
private int m_maxAdvanceWidth = 0;
|
||||
private int m_minRightSideBearing = 0;
|
||||
|
||||
public HheaWriter(GlyfWriter a_glyf, HeadWriter a_head) {
|
||||
super();
|
||||
|
||||
m_glyf = a_glyf;
|
||||
m_head = a_head;
|
||||
}
|
||||
|
||||
public void setLineGap(int a_value) {
|
||||
m_lineGap = a_value;
|
||||
}
|
||||
|
||||
public void setMaxAdvanceWidth(int a_value) {
|
||||
m_maxAdvanceWidth = a_value;
|
||||
}
|
||||
|
||||
public void setMinRightSideBearing(int a_value) {
|
||||
m_minRightSideBearing = a_value;
|
||||
}
|
||||
|
||||
public void write() throws IOException {
|
||||
// table version number
|
||||
writeFixed32(1.0);
|
||||
|
||||
writeFWord(m_head.getMax().y);
|
||||
writeFWord(m_head.getMin().y);
|
||||
writeFWord(m_lineGap);
|
||||
writeUFWord(m_maxAdvanceWidth);
|
||||
|
||||
int minLeftSideBearing = m_head.getMin().x;
|
||||
writeFWord(minLeftSideBearing);
|
||||
writeFWord(m_minRightSideBearing);
|
||||
|
||||
int xMaxExtent = m_head.getMax().x - m_head.getMin().x;
|
||||
writeFWord(xMaxExtent);
|
||||
|
||||
// caratSlopeRise
|
||||
writeInt16(1);
|
||||
writeInt16(0);
|
||||
|
||||
// reserved
|
||||
for (int i = 0; i < 5; i++) {
|
||||
writeInt16(0);
|
||||
} // for i
|
||||
|
||||
writeInt16(0);
|
||||
|
||||
int numOfHMetrics = m_glyf.numOfGlyph();
|
||||
writeUInt16(numOfHMetrics);
|
||||
|
||||
pad();
|
||||
}
|
||||
|
||||
protected String getTag() {
|
||||
return "hhea";
|
||||
}
|
||||
}
|
||||
/*
|
||||
* $Id: HheaWriter.java,v 1.5 2004/09/26 09:15:48 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
|
||||
package org.doubletype.ossa.truetype;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* HheaWriter depends on HtmxWriter.
|
||||
* @author e.e
|
||||
*/
|
||||
public class HheaWriter extends FontFormatWriter {
|
||||
private GlyfWriter m_glyf;
|
||||
private HeadWriter m_head;
|
||||
|
||||
private int m_lineGap = 0;
|
||||
private int m_maxAdvanceWidth = 0;
|
||||
private int m_minRightSideBearing = 0;
|
||||
|
||||
public HheaWriter(GlyfWriter a_glyf, HeadWriter a_head) {
|
||||
super();
|
||||
|
||||
m_glyf = a_glyf;
|
||||
m_head = a_head;
|
||||
}
|
||||
|
||||
public void setLineGap(int a_value) {
|
||||
m_lineGap = a_value;
|
||||
}
|
||||
|
||||
public void setMaxAdvanceWidth(int a_value) {
|
||||
m_maxAdvanceWidth = a_value;
|
||||
}
|
||||
|
||||
public void setMinRightSideBearing(int a_value) {
|
||||
m_minRightSideBearing = a_value;
|
||||
}
|
||||
|
||||
public void write() throws IOException {
|
||||
// table version number
|
||||
writeFixed32(1.0);
|
||||
|
||||
writeFWord(m_head.getMax().y);
|
||||
writeFWord(m_head.getMin().y);
|
||||
writeFWord(m_lineGap);
|
||||
writeUFWord(m_maxAdvanceWidth);
|
||||
|
||||
int minLeftSideBearing = m_head.getMin().x;
|
||||
writeFWord(minLeftSideBearing);
|
||||
writeFWord(m_minRightSideBearing);
|
||||
|
||||
int xMaxExtent = m_head.getMax().x - m_head.getMin().x;
|
||||
writeFWord(xMaxExtent);
|
||||
|
||||
// caratSlopeRise
|
||||
writeInt16(1);
|
||||
writeInt16(0);
|
||||
|
||||
// reserved
|
||||
for (int i = 0; i < 5; i++) {
|
||||
writeInt16(0);
|
||||
}
|
||||
|
||||
writeInt16(0);
|
||||
|
||||
int numOfHMetrics = m_glyf.numOfGlyph();
|
||||
writeUInt16(numOfHMetrics);
|
||||
|
||||
pad();
|
||||
}
|
||||
|
||||
protected String getTag() {
|
||||
return "hhea";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,89 +1,89 @@
|
||||
/*
|
||||
* $Id: HmtxWriter.java,v 1.10 2004/10/04 02:25:39 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
|
||||
package org.doubletype.ossa.truetype;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* HtmxWriter depends on GlyfWriter.
|
||||
*
|
||||
* @author e.e
|
||||
*/
|
||||
public class HmtxWriter extends FontFormatWriter {
|
||||
HheaWriter m_hhea;
|
||||
GlyfWriter m_glyf;
|
||||
|
||||
public HmtxWriter(GlyfWriter a_glyf, HheaWriter a_hhea) {
|
||||
super();
|
||||
|
||||
m_hhea = a_hhea;
|
||||
m_glyf = a_glyf;
|
||||
}
|
||||
|
||||
public void write() throws IOException {
|
||||
int i;
|
||||
|
||||
TTGlyph glyphZero = m_glyf.getGlyph(0);
|
||||
int maxWidth = glyphZero.getAdvanceWidth();
|
||||
int minRightSideBearing = glyphZero.getRightSideBearing();
|
||||
for (i = 0; i < m_glyf.numOfGlyph(); i++) {
|
||||
TTGlyph glyph = m_glyf.getGlyph(i);
|
||||
|
||||
if (glyph.getAdvanceWidth() > maxWidth) {
|
||||
maxWidth = glyph.getAdvanceWidth();
|
||||
} // if
|
||||
|
||||
if (glyph.getRightSideBearing() < minRightSideBearing) {
|
||||
minRightSideBearing = glyph.getRightSideBearing();
|
||||
} // if
|
||||
|
||||
writeUFWord(glyph.getAdvanceWidth());
|
||||
writeFWord(glyph.getLeftSideBearing());
|
||||
} // for i
|
||||
|
||||
writeFWord(0);
|
||||
|
||||
m_hhea.setMaxAdvanceWidth(maxWidth);
|
||||
m_hhea.setMinRightSideBearing(minRightSideBearing);
|
||||
|
||||
pad();
|
||||
}
|
||||
|
||||
protected String getTag() {
|
||||
return "hmtx";
|
||||
}
|
||||
}
|
||||
/*
|
||||
* $Id: HmtxWriter.java,v 1.10 2004/10/04 02:25:39 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
|
||||
package org.doubletype.ossa.truetype;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* HtmxWriter depends on GlyfWriter.
|
||||
*
|
||||
* @author e.e
|
||||
*/
|
||||
public class HmtxWriter extends FontFormatWriter {
|
||||
HheaWriter m_hhea;
|
||||
GlyfWriter m_glyf;
|
||||
|
||||
public HmtxWriter(GlyfWriter a_glyf, HheaWriter a_hhea) {
|
||||
super();
|
||||
|
||||
m_hhea = a_hhea;
|
||||
m_glyf = a_glyf;
|
||||
}
|
||||
|
||||
public void write() throws IOException {
|
||||
int i;
|
||||
|
||||
TTGlyph glyphZero = m_glyf.getGlyph(0);
|
||||
int maxWidth = glyphZero.getAdvanceWidth();
|
||||
int minRightSideBearing = glyphZero.getRightSideBearing();
|
||||
for (i = 0; i < m_glyf.numOfGlyph(); i++) {
|
||||
TTGlyph glyph = m_glyf.getGlyph(i);
|
||||
|
||||
if (glyph.getAdvanceWidth() > maxWidth) {
|
||||
maxWidth = glyph.getAdvanceWidth();
|
||||
}
|
||||
|
||||
if (glyph.getRightSideBearing() < minRightSideBearing) {
|
||||
minRightSideBearing = glyph.getRightSideBearing();
|
||||
}
|
||||
|
||||
writeUFWord(glyph.getAdvanceWidth());
|
||||
writeFWord(glyph.getLeftSideBearing());
|
||||
}
|
||||
|
||||
writeFWord(0);
|
||||
|
||||
m_hhea.setMaxAdvanceWidth(maxWidth);
|
||||
m_hhea.setMinRightSideBearing(minRightSideBearing);
|
||||
|
||||
pad();
|
||||
}
|
||||
|
||||
protected String getTag() {
|
||||
return "hmtx";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,67 +1,67 @@
|
||||
/*
|
||||
* $Id: LocaWriter.java,v 1.3 2004/01/15 07:06:27 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
|
||||
package org.doubletype.ossa.truetype;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class LocaWriter extends FontFormatWriter {
|
||||
public ArrayList<Integer> m_offsets = new ArrayList<>();
|
||||
|
||||
public LocaWriter() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void write() throws IOException {
|
||||
// assume glyf table is already written,
|
||||
// and offsets are stored in m_offsets
|
||||
|
||||
int i;
|
||||
for (i = 0; i < m_offsets.size(); i++) {
|
||||
writeUInt32(m_offsets.get(i));
|
||||
} // for i
|
||||
|
||||
pad();
|
||||
}
|
||||
|
||||
protected String getTag() {
|
||||
return "loca";
|
||||
}
|
||||
}
|
||||
/*
|
||||
* $Id: LocaWriter.java,v 1.3 2004/01/15 07:06:27 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
|
||||
package org.doubletype.ossa.truetype;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class LocaWriter extends FontFormatWriter {
|
||||
public ArrayList<Integer> m_offsets = new ArrayList<>();
|
||||
|
||||
public LocaWriter() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void write() throws IOException {
|
||||
// assume glyf table is already written,
|
||||
// and offsets are stored in m_offsets
|
||||
|
||||
int i;
|
||||
for (i = 0; i < m_offsets.size(); i++) {
|
||||
writeUInt32(m_offsets.get(i));
|
||||
}
|
||||
|
||||
pad();
|
||||
}
|
||||
|
||||
protected String getTag() {
|
||||
return "loca";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,137 +1,137 @@
|
||||
/*
|
||||
* $Id: MaxpWriter.java,v 1.11 2004/06/27 07:26:46 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
|
||||
package org.doubletype.ossa.truetype;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class MaxpWriter extends FontFormatWriter {
|
||||
private int m_numGlyphs = 98; // set by GlyfWriter
|
||||
private int m_maxPoints = 0;
|
||||
private int m_maxContours = 0;
|
||||
private int m_maxCompositePoints = 0;
|
||||
private int m_maxCompositeContours = 0;
|
||||
private int m_maxZones = 2;
|
||||
private int m_maxTwilightPoints = 128;
|
||||
private int m_maxStorage = 64;
|
||||
private int m_maxFunctionDefs = 128;
|
||||
private int m_maxInstructionDefs = 128;
|
||||
private int m_maxStackElements = 128;
|
||||
private int m_maxSizeOfInstructions = 128;
|
||||
private int m_maxComponentElements = 128;
|
||||
private int m_maxComponentDepth = 0;
|
||||
|
||||
public MaxpWriter() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void write() throws IOException {
|
||||
writeFixed32(1.0);
|
||||
writeUInt16(m_numGlyphs);
|
||||
writeUInt16(m_maxPoints);
|
||||
writeUInt16(m_maxContours);
|
||||
writeUInt16(m_maxCompositePoints);
|
||||
writeUInt16(m_maxCompositeContours);
|
||||
writeUInt16(m_maxZones);
|
||||
writeUInt16(m_maxTwilightPoints);
|
||||
writeUInt16(m_maxStorage);
|
||||
writeUInt16(m_maxFunctionDefs);
|
||||
writeUInt16(m_maxInstructionDefs);
|
||||
writeUInt16(m_maxStackElements);
|
||||
writeUInt16(m_maxSizeOfInstructions);
|
||||
writeUInt16(m_maxComponentElements);
|
||||
writeUInt16(m_maxComponentDepth);
|
||||
pad();
|
||||
}
|
||||
|
||||
protected String getTag() {
|
||||
return "maxp";
|
||||
}
|
||||
|
||||
/** set the number of glyphs in the font */
|
||||
public void setNumGlyphs(int a_value) {
|
||||
m_numGlyphs = a_value;
|
||||
}
|
||||
|
||||
/** update points in non-compound glyph */
|
||||
public void updateNumOfPoints(int a_value) {
|
||||
if (a_value > m_maxPoints) {
|
||||
m_maxPoints = a_value;
|
||||
} // if
|
||||
}
|
||||
|
||||
/** update points in non-compound glyph */
|
||||
public void updateNumOfContours(int a_value) {
|
||||
if (a_value > m_maxContours) {
|
||||
m_maxContours = a_value;
|
||||
} // if
|
||||
}
|
||||
|
||||
public void updateNumOfCompositePoints(int a_value) {
|
||||
if (a_value > m_maxCompositePoints) {
|
||||
m_maxCompositePoints = a_value;
|
||||
} // if
|
||||
}
|
||||
|
||||
public void updateNumOfCompositeContours(int a_value) {
|
||||
if (a_value > m_maxCompositeContours) {
|
||||
m_maxCompositeContours = a_value;
|
||||
} // if
|
||||
}
|
||||
|
||||
/** update byte count for glyph instructions */
|
||||
public void updateSizeOfInstructions(int a_value) {
|
||||
if (a_value > m_maxSizeOfInstructions) {
|
||||
m_maxSizeOfInstructions = a_value;
|
||||
} // if
|
||||
}
|
||||
|
||||
public void updateNumOfComponentElements(int a_value) {
|
||||
if (a_value > m_maxComponentElements) {
|
||||
m_maxComponentElements = a_value;
|
||||
} // if
|
||||
}
|
||||
|
||||
public void updateComponentDepth(int a_value) {
|
||||
if (a_value > m_maxComponentDepth) {
|
||||
m_maxComponentDepth = a_value;
|
||||
} // if
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* $Id: MaxpWriter.java,v 1.11 2004/06/27 07:26:46 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
|
||||
package org.doubletype.ossa.truetype;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class MaxpWriter extends FontFormatWriter {
|
||||
private int m_numGlyphs = 98; // set by GlyfWriter
|
||||
private int m_maxPoints = 0;
|
||||
private int m_maxContours = 0;
|
||||
private int m_maxCompositePoints = 0;
|
||||
private int m_maxCompositeContours = 0;
|
||||
private int m_maxZones = 2;
|
||||
private int m_maxTwilightPoints = 128;
|
||||
private int m_maxStorage = 64;
|
||||
private int m_maxFunctionDefs = 128;
|
||||
private int m_maxInstructionDefs = 128;
|
||||
private int m_maxStackElements = 128;
|
||||
private int m_maxSizeOfInstructions = 128;
|
||||
private int m_maxComponentElements = 128;
|
||||
private int m_maxComponentDepth = 0;
|
||||
|
||||
public MaxpWriter() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void write() throws IOException {
|
||||
writeFixed32(1.0);
|
||||
writeUInt16(m_numGlyphs);
|
||||
writeUInt16(m_maxPoints);
|
||||
writeUInt16(m_maxContours);
|
||||
writeUInt16(m_maxCompositePoints);
|
||||
writeUInt16(m_maxCompositeContours);
|
||||
writeUInt16(m_maxZones);
|
||||
writeUInt16(m_maxTwilightPoints);
|
||||
writeUInt16(m_maxStorage);
|
||||
writeUInt16(m_maxFunctionDefs);
|
||||
writeUInt16(m_maxInstructionDefs);
|
||||
writeUInt16(m_maxStackElements);
|
||||
writeUInt16(m_maxSizeOfInstructions);
|
||||
writeUInt16(m_maxComponentElements);
|
||||
writeUInt16(m_maxComponentDepth);
|
||||
pad();
|
||||
}
|
||||
|
||||
protected String getTag() {
|
||||
return "maxp";
|
||||
}
|
||||
|
||||
/** set the number of glyphs in the font */
|
||||
public void setNumGlyphs(int a_value) {
|
||||
m_numGlyphs = a_value;
|
||||
}
|
||||
|
||||
/** update points in non-compound glyph */
|
||||
public void updateNumOfPoints(int a_value) {
|
||||
if (a_value > m_maxPoints) {
|
||||
m_maxPoints = a_value;
|
||||
}
|
||||
}
|
||||
|
||||
/** update points in non-compound glyph */
|
||||
public void updateNumOfContours(int a_value) {
|
||||
if (a_value > m_maxContours) {
|
||||
m_maxContours = a_value;
|
||||
}
|
||||
}
|
||||
|
||||
public void updateNumOfCompositePoints(int a_value) {
|
||||
if (a_value > m_maxCompositePoints) {
|
||||
m_maxCompositePoints = a_value;
|
||||
}
|
||||
}
|
||||
|
||||
public void updateNumOfCompositeContours(int a_value) {
|
||||
if (a_value > m_maxCompositeContours) {
|
||||
m_maxCompositeContours = a_value;
|
||||
}
|
||||
}
|
||||
|
||||
/** update byte count for glyph instructions */
|
||||
public void updateSizeOfInstructions(int a_value) {
|
||||
if (a_value > m_maxSizeOfInstructions) {
|
||||
m_maxSizeOfInstructions = a_value;
|
||||
}
|
||||
}
|
||||
|
||||
public void updateNumOfComponentElements(int a_value) {
|
||||
if (a_value > m_maxComponentElements) {
|
||||
m_maxComponentElements = a_value;
|
||||
}
|
||||
}
|
||||
|
||||
public void updateComponentDepth(int a_value) {
|
||||
if (a_value > m_maxComponentDepth) {
|
||||
m_maxComponentDepth = a_value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,183 +1,183 @@
|
||||
/*
|
||||
* $Id: NameWriter.java,v 1.9 2004/06/16 07:02:52 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
|
||||
package org.doubletype.ossa.truetype;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class NameWriter extends FontFormatWriter {
|
||||
public static final String k_regular = "Regular";
|
||||
private static final String k_utf16be = "UTF-16BE";
|
||||
private static final String k_iso8859_1 = "ISO-8859-1";
|
||||
|
||||
String m_copyright = "\u00A9 Copyright";
|
||||
String m_familyName = "Temp";
|
||||
String m_subFamilyName = k_regular;
|
||||
String m_unique = "eed3si9n: Temp Regular: 2003";
|
||||
String m_fullFontName = "Temp";
|
||||
String m_version = "0.00";
|
||||
String m_psName = "Temp";
|
||||
String m_tradeMark = "";
|
||||
String m_manufacturer = "eed3si9n";
|
||||
String m_year = "2004";
|
||||
String m_sample = "The quick brown fox jumps over the lazy dog.";
|
||||
|
||||
private ArrayList<TTName> m_names = new ArrayList<>();
|
||||
|
||||
public NameWriter() {
|
||||
super();
|
||||
}
|
||||
|
||||
private void prepare() {
|
||||
m_copyright = "\u00A9 Copyright "
|
||||
+ m_year
|
||||
+ ", "
|
||||
+ m_manufacturer
|
||||
+ ".";
|
||||
m_unique = "dtype: "
|
||||
+ m_manufacturer + ": "
|
||||
+ m_familyName + " "
|
||||
+ m_subFamilyName + ": "
|
||||
+ "Version " + m_version + ": "
|
||||
+ m_year;
|
||||
m_fullFontName = m_familyName;
|
||||
m_psName = m_fullFontName;
|
||||
|
||||
if (m_tradeMark.length() == 0) {
|
||||
m_tradeMark = "n/a";
|
||||
} // if
|
||||
|
||||
m_names.clear();
|
||||
addNames();
|
||||
}
|
||||
|
||||
private void addNames() {
|
||||
addMacintoshRomanEnglish(0, m_copyright);
|
||||
addMacintoshRomanEnglish(1, m_familyName);
|
||||
addMacintoshRomanEnglish(2, m_subFamilyName);
|
||||
addMacintoshRomanEnglish(3, m_unique);
|
||||
addMacintoshRomanEnglish(4, m_fullFontName);
|
||||
addMacintoshRomanEnglish(5, "Version " + m_version);
|
||||
addMacintoshRomanEnglish(6, m_psName);
|
||||
addMacintoshRomanEnglish(7, m_tradeMark);
|
||||
addMacintoshRomanEnglish(8, m_manufacturer);
|
||||
|
||||
addMicrosoftUnicodeEnglish(0, m_copyright);
|
||||
addMicrosoftUnicodeEnglish(1, m_familyName);
|
||||
addMicrosoftUnicodeEnglish(2, m_subFamilyName);
|
||||
addMicrosoftUnicodeEnglish(3, m_unique);
|
||||
addMicrosoftUnicodeEnglish(4, m_fullFontName);
|
||||
addMicrosoftUnicodeEnglish(5, "Version " + m_version);
|
||||
addMicrosoftUnicodeEnglish(6, m_psName);
|
||||
addMicrosoftUnicodeEnglish(7, m_tradeMark);
|
||||
addMicrosoftUnicodeEnglish(8, m_manufacturer);
|
||||
// addMicrosoftUnicodeEnglish(19, m_sample);
|
||||
}
|
||||
|
||||
private void addMacintoshRomanEnglish(int a_nameId, String a_value) {
|
||||
try {
|
||||
add(TTName.k_macintosh,
|
||||
TTName.k_macRomanEncode,
|
||||
TTName.k_macEnglishLang,
|
||||
a_nameId,
|
||||
a_value.getBytes(k_iso8859_1));
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} // try-catch
|
||||
}
|
||||
|
||||
private void addMicrosoftUnicodeEnglish(int a_nameId, String a_value) {
|
||||
try {
|
||||
add(TTName.k_microsoft,
|
||||
TTName.k_winUnicodeEncode,
|
||||
TTName.k_winEnglishLang,
|
||||
a_nameId,
|
||||
a_value.getBytes(k_utf16be));
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void add(int a_platformId, int a_encodingId, int a_languageId,
|
||||
int a_nameId, byte a_bytes[]) {
|
||||
TTName name = new TTName(a_platformId,
|
||||
a_encodingId,
|
||||
a_languageId,
|
||||
a_nameId,
|
||||
a_bytes);
|
||||
m_names.add(name);
|
||||
}
|
||||
|
||||
public void write() throws IOException {
|
||||
prepare();
|
||||
|
||||
// table version number
|
||||
writeUInt16(0);
|
||||
|
||||
// number of name records
|
||||
writeUInt16(m_names.size());
|
||||
|
||||
// Offset to start of string storage (from start of table).
|
||||
writeUInt16(12 * m_names.size() + 6);
|
||||
|
||||
int offset = 0;
|
||||
for (TTName name: m_names) {
|
||||
writeUInt16(name.getPlatformId());
|
||||
writeUInt16(name.getEncodingId());
|
||||
writeUInt16(name.getLanguageId());
|
||||
writeUInt16(name.getNameId());
|
||||
writeUInt16(name.getStringLength());
|
||||
writeUInt16(offset);
|
||||
offset += name.getStringLength();
|
||||
} // for i
|
||||
|
||||
for (TTName name: m_names) {
|
||||
m_buffer.write(name.getBytes());
|
||||
} // for i
|
||||
|
||||
pad();
|
||||
}
|
||||
|
||||
protected String getTag() {
|
||||
return "name";
|
||||
}
|
||||
}
|
||||
/*
|
||||
* $Id: NameWriter.java,v 1.9 2004/06/16 07:02:52 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
|
||||
package org.doubletype.ossa.truetype;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class NameWriter extends FontFormatWriter {
|
||||
public static final String k_regular = "Regular";
|
||||
private static final String k_utf16be = "UTF-16BE";
|
||||
private static final String k_iso8859_1 = "ISO-8859-1";
|
||||
|
||||
String m_copyright = "\u00A9 Copyright";
|
||||
String m_familyName = "Temp";
|
||||
String m_subFamilyName = k_regular;
|
||||
String m_unique = "eed3si9n: Temp Regular: 2003";
|
||||
String m_fullFontName = "Temp";
|
||||
String m_version = "0.00";
|
||||
String m_psName = "Temp";
|
||||
String m_tradeMark = "";
|
||||
String m_manufacturer = "eed3si9n";
|
||||
String m_year = "2004";
|
||||
String m_sample = "The quick brown fox jumps over the lazy dog.";
|
||||
|
||||
private ArrayList<TTName> m_names = new ArrayList<>();
|
||||
|
||||
public NameWriter() {
|
||||
super();
|
||||
}
|
||||
|
||||
private void prepare() {
|
||||
m_copyright = "\u00A9 Copyright "
|
||||
+ m_year
|
||||
+ ", "
|
||||
+ m_manufacturer
|
||||
+ ".";
|
||||
m_unique = "dtype: "
|
||||
+ m_manufacturer + ": "
|
||||
+ m_familyName + " "
|
||||
+ m_subFamilyName + ": "
|
||||
+ "Version " + m_version + ": "
|
||||
+ m_year;
|
||||
m_fullFontName = m_familyName;
|
||||
m_psName = m_fullFontName;
|
||||
|
||||
if (m_tradeMark.length() == 0) {
|
||||
m_tradeMark = "n/a";
|
||||
}
|
||||
|
||||
m_names.clear();
|
||||
addNames();
|
||||
}
|
||||
|
||||
private void addNames() {
|
||||
addMacintoshRomanEnglish(0, m_copyright);
|
||||
addMacintoshRomanEnglish(1, m_familyName);
|
||||
addMacintoshRomanEnglish(2, m_subFamilyName);
|
||||
addMacintoshRomanEnglish(3, m_unique);
|
||||
addMacintoshRomanEnglish(4, m_fullFontName);
|
||||
addMacintoshRomanEnglish(5, "Version " + m_version);
|
||||
addMacintoshRomanEnglish(6, m_psName);
|
||||
addMacintoshRomanEnglish(7, m_tradeMark);
|
||||
addMacintoshRomanEnglish(8, m_manufacturer);
|
||||
|
||||
addMicrosoftUnicodeEnglish(0, m_copyright);
|
||||
addMicrosoftUnicodeEnglish(1, m_familyName);
|
||||
addMicrosoftUnicodeEnglish(2, m_subFamilyName);
|
||||
addMicrosoftUnicodeEnglish(3, m_unique);
|
||||
addMicrosoftUnicodeEnglish(4, m_fullFontName);
|
||||
addMicrosoftUnicodeEnglish(5, "Version " + m_version);
|
||||
addMicrosoftUnicodeEnglish(6, m_psName);
|
||||
addMicrosoftUnicodeEnglish(7, m_tradeMark);
|
||||
addMicrosoftUnicodeEnglish(8, m_manufacturer);
|
||||
// addMicrosoftUnicodeEnglish(19, m_sample);
|
||||
}
|
||||
|
||||
private void addMacintoshRomanEnglish(int a_nameId, String a_value) {
|
||||
try {
|
||||
add(TTName.k_macintosh,
|
||||
TTName.k_macRomanEncode,
|
||||
TTName.k_macEnglishLang,
|
||||
a_nameId,
|
||||
a_value.getBytes(k_iso8859_1));
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} // try-catch
|
||||
}
|
||||
|
||||
private void addMicrosoftUnicodeEnglish(int a_nameId, String a_value) {
|
||||
try {
|
||||
add(TTName.k_microsoft,
|
||||
TTName.k_winUnicodeEncode,
|
||||
TTName.k_winEnglishLang,
|
||||
a_nameId,
|
||||
a_value.getBytes(k_utf16be));
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void add(int a_platformId, int a_encodingId, int a_languageId,
|
||||
int a_nameId, byte a_bytes[]) {
|
||||
TTName name = new TTName(a_platformId,
|
||||
a_encodingId,
|
||||
a_languageId,
|
||||
a_nameId,
|
||||
a_bytes);
|
||||
m_names.add(name);
|
||||
}
|
||||
|
||||
public void write() throws IOException {
|
||||
prepare();
|
||||
|
||||
// table version number
|
||||
writeUInt16(0);
|
||||
|
||||
// number of name records
|
||||
writeUInt16(m_names.size());
|
||||
|
||||
// Offset to start of string storage (from start of table).
|
||||
writeUInt16(12 * m_names.size() + 6);
|
||||
|
||||
int offset = 0;
|
||||
for (TTName name: m_names) {
|
||||
writeUInt16(name.getPlatformId());
|
||||
writeUInt16(name.getEncodingId());
|
||||
writeUInt16(name.getLanguageId());
|
||||
writeUInt16(name.getNameId());
|
||||
writeUInt16(name.getStringLength());
|
||||
writeUInt16(offset);
|
||||
offset += name.getStringLength();
|
||||
}
|
||||
|
||||
for (TTName name: m_names) {
|
||||
m_buffer.write(name.getBytes());
|
||||
}
|
||||
|
||||
pad();
|
||||
}
|
||||
|
||||
protected String getTag() {
|
||||
return "name";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,242 +1,242 @@
|
||||
/*
|
||||
* $Id: OS2Writer.java,v 1.11 2004/10/04 02:25:39 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
|
||||
package org.doubletype.ossa.truetype;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class OS2Writer extends FontFormatWriter {
|
||||
final int FW_THIN = 100;
|
||||
final int FW_EXTRALIGHT = 200;
|
||||
final int FW_LIGHT = 300;
|
||||
final int FW_NORMAL = 400;
|
||||
final int FW_MEDIUM = 500;
|
||||
final int FW_SEMIBOLD = 600;
|
||||
final int FW_BOLD = 700;
|
||||
final int FW_EXTRABOLD = 800;
|
||||
final int FW_BLACK = 900;
|
||||
|
||||
final int FWIDTH_NORMAL = 5;
|
||||
|
||||
final int k_editableEmbedding = 0x0008;
|
||||
|
||||
final int k_sansSerif = 0x0800;
|
||||
|
||||
// unicode
|
||||
final int k_basicLatin = 0x0001;
|
||||
final int k_latin1Supplement = 0x0002;
|
||||
|
||||
final int k_regular = 0x40;
|
||||
final int k_basicLatinStart = 0x0020;
|
||||
final int k_basciLatinEnd = 0x007e;
|
||||
|
||||
private HeadWriter m_head;
|
||||
|
||||
int m_xAvgCharWidth = 512;
|
||||
int m_usWeightClass = FW_NORMAL;
|
||||
int m_usWidthClass = FWIDTH_NORMAL;
|
||||
int m_fsType = 0;
|
||||
int m_ySubscriptXSize = 128;
|
||||
int m_ySubscriptYSize = 128;
|
||||
int m_ySubscriptXOffset = 0;
|
||||
int m_ySubscriptYOffset = -64;
|
||||
int m_ySuperscriptXSize = 128;
|
||||
int m_ySuperscriptYSize = 128;
|
||||
int m_ySuperscriptXOffset = 0;
|
||||
int m_ySuperscriptYOffset = 64;
|
||||
int m_yStrikeoutSize = 51;
|
||||
int m_yStrikeoutPosition = 512;
|
||||
int m_sFamilyClass = k_sansSerif;
|
||||
|
||||
long m_ulUnicodeRange1 = k_basicLatin | k_latin1Supplement;
|
||||
long m_ulUnicodeRange2 = 0;
|
||||
long m_ulUnicodeRange3 = 0;
|
||||
long m_ulUnicodeRange4 = 0;
|
||||
String m_vendId = "dtyp";
|
||||
int m_fsSelection = k_regular;
|
||||
int m_usFirstCharIndex = k_basicLatinStart;
|
||||
int m_usLastCharIndex = k_basciLatinEnd;
|
||||
private int m_sTypoAscender = 1024;
|
||||
private int m_sTypoDescender = 0;
|
||||
private int m_sTypoLineGap = 0;
|
||||
private int m_usWinAscent = 1024;
|
||||
private int m_usWinDescent = 0;
|
||||
long m_ulCodePageRange1 = 0;
|
||||
long m_ulCodePageRange2 = 0;
|
||||
private int m_sxHeight = 512;
|
||||
private int m_sCapHeight = 1024;
|
||||
int m_usDefaultChar = 0x0;
|
||||
int m_usBreakChar = 0x20;
|
||||
int m_usMaxContext = 1;
|
||||
|
||||
public OS2Writer(HeadWriter a_head) {
|
||||
super();
|
||||
|
||||
m_head = a_head;
|
||||
}
|
||||
|
||||
public void setCapHeight(int a_value) {
|
||||
m_sCapHeight = a_value;
|
||||
}
|
||||
|
||||
public void setXHeight(int a_value) {
|
||||
m_sxHeight = a_value;
|
||||
}
|
||||
|
||||
public void setTypoAscender(int a_value) {
|
||||
m_sTypoAscender = a_value;
|
||||
}
|
||||
|
||||
public void setTypoDescender(int a_value) {
|
||||
m_sTypoDescender = a_value;
|
||||
}
|
||||
|
||||
public void setTypoLineGap(int a_value) {
|
||||
m_sTypoLineGap = a_value;
|
||||
}
|
||||
|
||||
public void setUnicodeRangeFlag(int a_pos) {
|
||||
int which = a_pos / 32;
|
||||
int where = a_pos % 32;
|
||||
long what = 0x1 << where;
|
||||
|
||||
switch (which) {
|
||||
case 0: {
|
||||
m_ulUnicodeRange1 |= what;
|
||||
} break;
|
||||
|
||||
case 1: {
|
||||
m_ulUnicodeRange2 |= what;
|
||||
} break;
|
||||
|
||||
case 2: {
|
||||
m_ulUnicodeRange3 |= what;
|
||||
} break;
|
||||
|
||||
case 3: {
|
||||
m_ulUnicodeRange4 |= what;
|
||||
} break;
|
||||
} // switch
|
||||
}
|
||||
|
||||
public void setCodePageRangeFlag(int a_pos) {
|
||||
int which = a_pos / 32;
|
||||
int where = a_pos % 32;
|
||||
long what = 0x1 << where;
|
||||
|
||||
switch (which) {
|
||||
case 0: {
|
||||
m_ulCodePageRange1 |= what;
|
||||
} break;
|
||||
|
||||
case 1: {
|
||||
m_ulCodePageRange2 |= what;
|
||||
} break;
|
||||
} // switch
|
||||
}
|
||||
|
||||
public void write() throws IOException {
|
||||
m_usWinAscent = m_head.getMax().y;
|
||||
m_usWinDescent = 0;
|
||||
if (m_head.getMin().y < 0) {
|
||||
m_usWinDescent = -m_head.getMin().y;
|
||||
} // if
|
||||
|
||||
// table version number
|
||||
writeUInt16(0x02);
|
||||
|
||||
writeInt16(m_xAvgCharWidth);
|
||||
writeUInt16(m_usWeightClass);
|
||||
writeUInt16(m_usWidthClass);
|
||||
writeInt16(m_fsType);
|
||||
writeInt16(m_ySubscriptXSize);
|
||||
writeInt16(m_ySubscriptYSize);
|
||||
writeInt16(m_ySubscriptXOffset);
|
||||
writeInt16(m_ySubscriptYOffset);
|
||||
writeInt16(m_ySuperscriptXSize);
|
||||
writeInt16(m_ySuperscriptYSize);
|
||||
writeInt16(m_ySuperscriptXOffset);
|
||||
writeInt16(m_ySuperscriptYOffset);
|
||||
writeInt16(m_yStrikeoutSize);
|
||||
writeInt16(m_yStrikeoutPosition);
|
||||
writeInt16(m_sFamilyClass);
|
||||
|
||||
writePanose();
|
||||
|
||||
writeUInt32(m_ulUnicodeRange1);
|
||||
writeUInt32(m_ulUnicodeRange2);
|
||||
writeUInt32(m_ulUnicodeRange3);
|
||||
writeUInt32(m_ulUnicodeRange4);
|
||||
writeTag(m_vendId);
|
||||
writeUInt16(m_fsSelection);
|
||||
writeUInt16(m_usFirstCharIndex);
|
||||
writeUInt16(m_usLastCharIndex);
|
||||
writeUInt16(m_sTypoAscender);
|
||||
writeUInt16(m_sTypoDescender);
|
||||
writeUInt16(m_sTypoLineGap);
|
||||
writeUInt16(m_usWinAscent);
|
||||
writeUInt16(m_usWinDescent);
|
||||
writeUInt32(m_ulCodePageRange1);
|
||||
writeUInt32(m_ulCodePageRange2);
|
||||
writeInt16(m_sxHeight);
|
||||
writeInt16(m_sCapHeight);
|
||||
writeUInt16(m_usDefaultChar);
|
||||
writeUInt16(m_usBreakChar);
|
||||
writeUInt16(m_usMaxContext);
|
||||
|
||||
pad();
|
||||
}
|
||||
|
||||
private void writePanose() throws IOException {
|
||||
writeUInt8(0); // family
|
||||
writeUInt8(0); // serif
|
||||
writeUInt8(0); // weight
|
||||
writeUInt8(0); // proportion
|
||||
writeUInt8(0); // contrast
|
||||
writeUInt8(0); // stroke
|
||||
writeUInt8(0); // arm style
|
||||
writeUInt8(0); // letterform
|
||||
writeUInt8(0); // midline
|
||||
writeUInt8(0); // x-height
|
||||
}
|
||||
|
||||
protected String getTag() {
|
||||
return "OS/2 ";
|
||||
}
|
||||
}
|
||||
/*
|
||||
* $Id: OS2Writer.java,v 1.11 2004/10/04 02:25:39 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
|
||||
package org.doubletype.ossa.truetype;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class OS2Writer extends FontFormatWriter {
|
||||
final int FW_THIN = 100;
|
||||
final int FW_EXTRALIGHT = 200;
|
||||
final int FW_LIGHT = 300;
|
||||
final int FW_NORMAL = 400;
|
||||
final int FW_MEDIUM = 500;
|
||||
final int FW_SEMIBOLD = 600;
|
||||
final int FW_BOLD = 700;
|
||||
final int FW_EXTRABOLD = 800;
|
||||
final int FW_BLACK = 900;
|
||||
|
||||
final int FWIDTH_NORMAL = 5;
|
||||
|
||||
final int k_editableEmbedding = 0x0008;
|
||||
|
||||
final int k_sansSerif = 0x0800;
|
||||
|
||||
// unicode
|
||||
final int k_basicLatin = 0x0001;
|
||||
final int k_latin1Supplement = 0x0002;
|
||||
|
||||
final int k_regular = 0x40;
|
||||
final int k_basicLatinStart = 0x0020;
|
||||
final int k_basciLatinEnd = 0x007e;
|
||||
|
||||
private HeadWriter m_head;
|
||||
|
||||
int m_xAvgCharWidth = 512;
|
||||
int m_usWeightClass = FW_NORMAL;
|
||||
int m_usWidthClass = FWIDTH_NORMAL;
|
||||
int m_fsType = 0;
|
||||
int m_ySubscriptXSize = 128;
|
||||
int m_ySubscriptYSize = 128;
|
||||
int m_ySubscriptXOffset = 0;
|
||||
int m_ySubscriptYOffset = -64;
|
||||
int m_ySuperscriptXSize = 128;
|
||||
int m_ySuperscriptYSize = 128;
|
||||
int m_ySuperscriptXOffset = 0;
|
||||
int m_ySuperscriptYOffset = 64;
|
||||
int m_yStrikeoutSize = 51;
|
||||
int m_yStrikeoutPosition = 512;
|
||||
int m_sFamilyClass = k_sansSerif;
|
||||
|
||||
long m_ulUnicodeRange1 = k_basicLatin | k_latin1Supplement;
|
||||
long m_ulUnicodeRange2 = 0;
|
||||
long m_ulUnicodeRange3 = 0;
|
||||
long m_ulUnicodeRange4 = 0;
|
||||
String m_vendId = "dtyp";
|
||||
int m_fsSelection = k_regular;
|
||||
int m_usFirstCharIndex = k_basicLatinStart;
|
||||
int m_usLastCharIndex = k_basciLatinEnd;
|
||||
private int m_sTypoAscender = 1024;
|
||||
private int m_sTypoDescender = 0;
|
||||
private int m_sTypoLineGap = 0;
|
||||
private int m_usWinAscent = 1024;
|
||||
private int m_usWinDescent = 0;
|
||||
long m_ulCodePageRange1 = 0;
|
||||
long m_ulCodePageRange2 = 0;
|
||||
private int m_sxHeight = 512;
|
||||
private int m_sCapHeight = 1024;
|
||||
int m_usDefaultChar = 0x0;
|
||||
int m_usBreakChar = 0x20;
|
||||
int m_usMaxContext = 1;
|
||||
|
||||
public OS2Writer(HeadWriter a_head) {
|
||||
super();
|
||||
|
||||
m_head = a_head;
|
||||
}
|
||||
|
||||
public void setCapHeight(int a_value) {
|
||||
m_sCapHeight = a_value;
|
||||
}
|
||||
|
||||
public void setXHeight(int a_value) {
|
||||
m_sxHeight = a_value;
|
||||
}
|
||||
|
||||
public void setTypoAscender(int a_value) {
|
||||
m_sTypoAscender = a_value;
|
||||
}
|
||||
|
||||
public void setTypoDescender(int a_value) {
|
||||
m_sTypoDescender = a_value;
|
||||
}
|
||||
|
||||
public void setTypoLineGap(int a_value) {
|
||||
m_sTypoLineGap = a_value;
|
||||
}
|
||||
|
||||
public void setUnicodeRangeFlag(int a_pos) {
|
||||
int which = a_pos / 32;
|
||||
int where = a_pos % 32;
|
||||
long what = 0x1 << where;
|
||||
|
||||
switch (which) {
|
||||
case 0: {
|
||||
m_ulUnicodeRange1 |= what;
|
||||
} break;
|
||||
|
||||
case 1: {
|
||||
m_ulUnicodeRange2 |= what;
|
||||
} break;
|
||||
|
||||
case 2: {
|
||||
m_ulUnicodeRange3 |= what;
|
||||
} break;
|
||||
|
||||
case 3: {
|
||||
m_ulUnicodeRange4 |= what;
|
||||
} break;
|
||||
} // switch
|
||||
}
|
||||
|
||||
public void setCodePageRangeFlag(int a_pos) {
|
||||
int which = a_pos / 32;
|
||||
int where = a_pos % 32;
|
||||
long what = 0x1 << where;
|
||||
|
||||
switch (which) {
|
||||
case 0: {
|
||||
m_ulCodePageRange1 |= what;
|
||||
} break;
|
||||
|
||||
case 1: {
|
||||
m_ulCodePageRange2 |= what;
|
||||
} break;
|
||||
} // switch
|
||||
}
|
||||
|
||||
public void write() throws IOException {
|
||||
m_usWinAscent = m_head.getMax().y;
|
||||
m_usWinDescent = 0;
|
||||
if (m_head.getMin().y < 0) {
|
||||
m_usWinDescent = -m_head.getMin().y;
|
||||
}
|
||||
|
||||
// table version number
|
||||
writeUInt16(0x02);
|
||||
|
||||
writeInt16(m_xAvgCharWidth);
|
||||
writeUInt16(m_usWeightClass);
|
||||
writeUInt16(m_usWidthClass);
|
||||
writeInt16(m_fsType);
|
||||
writeInt16(m_ySubscriptXSize);
|
||||
writeInt16(m_ySubscriptYSize);
|
||||
writeInt16(m_ySubscriptXOffset);
|
||||
writeInt16(m_ySubscriptYOffset);
|
||||
writeInt16(m_ySuperscriptXSize);
|
||||
writeInt16(m_ySuperscriptYSize);
|
||||
writeInt16(m_ySuperscriptXOffset);
|
||||
writeInt16(m_ySuperscriptYOffset);
|
||||
writeInt16(m_yStrikeoutSize);
|
||||
writeInt16(m_yStrikeoutPosition);
|
||||
writeInt16(m_sFamilyClass);
|
||||
|
||||
writePanose();
|
||||
|
||||
writeUInt32(m_ulUnicodeRange1);
|
||||
writeUInt32(m_ulUnicodeRange2);
|
||||
writeUInt32(m_ulUnicodeRange3);
|
||||
writeUInt32(m_ulUnicodeRange4);
|
||||
writeTag(m_vendId);
|
||||
writeUInt16(m_fsSelection);
|
||||
writeUInt16(m_usFirstCharIndex);
|
||||
writeUInt16(m_usLastCharIndex);
|
||||
writeUInt16(m_sTypoAscender);
|
||||
writeUInt16(m_sTypoDescender);
|
||||
writeUInt16(m_sTypoLineGap);
|
||||
writeUInt16(m_usWinAscent);
|
||||
writeUInt16(m_usWinDescent);
|
||||
writeUInt32(m_ulCodePageRange1);
|
||||
writeUInt32(m_ulCodePageRange2);
|
||||
writeInt16(m_sxHeight);
|
||||
writeInt16(m_sCapHeight);
|
||||
writeUInt16(m_usDefaultChar);
|
||||
writeUInt16(m_usBreakChar);
|
||||
writeUInt16(m_usMaxContext);
|
||||
|
||||
pad();
|
||||
}
|
||||
|
||||
private void writePanose() throws IOException {
|
||||
writeUInt8(0); // family
|
||||
writeUInt8(0); // serif
|
||||
writeUInt8(0); // weight
|
||||
writeUInt8(0); // proportion
|
||||
writeUInt8(0); // contrast
|
||||
writeUInt8(0); // stroke
|
||||
writeUInt8(0); // arm style
|
||||
writeUInt8(0); // letterform
|
||||
writeUInt8(0); // midline
|
||||
writeUInt8(0); // x-height
|
||||
}
|
||||
|
||||
protected String getTag() {
|
||||
return "OS/2 ";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,76 +1,76 @@
|
||||
/*
|
||||
* $Id: PostWriter.java,v 1.3 2004/01/11 13:14:45 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
|
||||
package org.doubletype.ossa.truetype;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class PostWriter extends FontFormatWriter {
|
||||
boolean m_isMonospaced = false;
|
||||
|
||||
public PostWriter() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void write() throws IOException {
|
||||
// table version number
|
||||
writeFixed32(1.0);
|
||||
writeFixed32(10.0); // italic angle
|
||||
writeFWord(0); // underline pos
|
||||
writeFWord(60); // underline thickness
|
||||
|
||||
if (m_isMonospaced) {
|
||||
writeUInt32(1); // fixed pitch
|
||||
} else {
|
||||
writeUInt32(0);
|
||||
} // if
|
||||
|
||||
// vm memory stuff
|
||||
writeUInt32(0);
|
||||
writeUInt32(0);
|
||||
writeUInt32(0);
|
||||
writeUInt32(0);
|
||||
|
||||
pad();
|
||||
}
|
||||
|
||||
protected String getTag() {
|
||||
return "post";
|
||||
}
|
||||
}
|
||||
/*
|
||||
* $Id: PostWriter.java,v 1.3 2004/01/11 13:14:45 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
|
||||
package org.doubletype.ossa.truetype;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class PostWriter extends FontFormatWriter {
|
||||
boolean m_isMonospaced = false;
|
||||
|
||||
public PostWriter() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void write() throws IOException {
|
||||
// table version number
|
||||
writeFixed32(1.0);
|
||||
writeFixed32(10.0); // italic angle
|
||||
writeFWord(0); // underline pos
|
||||
writeFWord(60); // underline thickness
|
||||
|
||||
if (m_isMonospaced) {
|
||||
writeUInt32(1); // fixed pitch
|
||||
} else {
|
||||
writeUInt32(0);
|
||||
}
|
||||
|
||||
// vm memory stuff
|
||||
writeUInt32(0);
|
||||
writeUInt32(0);
|
||||
writeUInt32(0);
|
||||
writeUInt32(0);
|
||||
|
||||
pad();
|
||||
}
|
||||
|
||||
protected String getTag() {
|
||||
return "post";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,189 +1,189 @@
|
||||
/*
|
||||
* $Id: TTCodePage.java,v 1.3 2004/05/16 12:59:07 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003-2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.truetype;
|
||||
|
||||
import java.util.*;
|
||||
import java.nio.charset.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class TTCodePage {
|
||||
static public TTCodePage US_ASCII = new TTCodePage("US-ASCII",
|
||||
"US-ASCII",
|
||||
64);
|
||||
static public TTCodePage Latin_1 = new TTCodePage("windows-1252",
|
||||
"Latin 1 windows-1252",
|
||||
0);
|
||||
static private boolean s_isInitialized = false;
|
||||
static private ArrayList<TTCodePage> s_list = new ArrayList<>();
|
||||
|
||||
static public String [] getNames() {
|
||||
initList();
|
||||
String [] retval = new String[s_list.size()];
|
||||
int i;
|
||||
for (i = 0; i < s_list.size(); i++) {
|
||||
TTCodePage codePage = (TTCodePage) s_list.get(i);
|
||||
retval[i] = codePage.getName();
|
||||
} // for i
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static public TTCodePage forName(String a_name) {
|
||||
initList();
|
||||
|
||||
TTCodePage retval = null;
|
||||
for (TTCodePage codePage: s_list) {
|
||||
if (codePage.getName().equals(a_name)) {
|
||||
return codePage;
|
||||
}
|
||||
} // for
|
||||
|
||||
for (TTCodePage codePage: s_list) {
|
||||
if (codePage.getCharset() == null) {
|
||||
continue;
|
||||
} // if
|
||||
|
||||
if (codePage.getCharset().name().equals(a_name)) {
|
||||
return codePage;
|
||||
}
|
||||
} // for
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static private void initList() {
|
||||
if (s_isInitialized)
|
||||
return;
|
||||
|
||||
s_isInitialized = true;
|
||||
|
||||
s_list.add(US_ASCII);
|
||||
s_list.add(Latin_1);
|
||||
s_list.add(new TTCodePage("ISO-2022-JP",
|
||||
"Japan-JIS",
|
||||
17));
|
||||
s_list.add(new TTCodePage("windows-1250",
|
||||
"Latin 2: Eastern Europe windows-1250",
|
||||
1));
|
||||
s_list.add(new TTCodePage("windows-1251",
|
||||
"Cyrillic windows-1251",
|
||||
2));
|
||||
s_list.add(new TTCodePage("windows-1253",
|
||||
"Greek windows-1253",
|
||||
3));
|
||||
s_list.add(new TTCodePage("windows-1254",
|
||||
"Turkish windows-1254",
|
||||
4));
|
||||
s_list.add(new TTCodePage("windows-1258",
|
||||
"Vietnamese windows-1258",
|
||||
8));
|
||||
|
||||
|
||||
// extended
|
||||
s_list.add(new TTCodePage("windows-1255",
|
||||
"Hebrew windows-1255",
|
||||
5));
|
||||
s_list.add(new TTCodePage("windows-1256",
|
||||
"Arabic windows-1256",
|
||||
6));
|
||||
s_list.add(new TTCodePage("windows-1257",
|
||||
"Windows Baltic",
|
||||
7));
|
||||
|
||||
// TODO: 16 Thai 874
|
||||
s_list.add(new TTCodePage(
|
||||
"Thai windows-874",
|
||||
16));
|
||||
|
||||
s_list.add(new TTCodePage("x-mswin-936",
|
||||
"Chinese: Simplified",
|
||||
18));
|
||||
|
||||
// TODO: 19 Korean Wansung
|
||||
s_list.add(new TTCodePage(
|
||||
"Korean Wansung",
|
||||
19));
|
||||
|
||||
s_list.add(new TTCodePage("x-windows-950",
|
||||
"Chinese: Traditional",
|
||||
20));
|
||||
}
|
||||
|
||||
|
||||
private String m_name;
|
||||
|
||||
/** http://www.microsoft.com/typography/otspec/os2.htm
|
||||
*/
|
||||
private int m_osTwoFlag = 0;
|
||||
private Charset m_charset = null;
|
||||
|
||||
public TTCodePage(String a_charsetName, String a_name,
|
||||
int a_osTwoFlag)
|
||||
{
|
||||
if (Charset.isSupported(a_charsetName)) {
|
||||
m_charset = Charset.forName(a_charsetName);
|
||||
} // if
|
||||
|
||||
m_name = a_name;
|
||||
m_osTwoFlag = a_osTwoFlag;
|
||||
}
|
||||
|
||||
public TTCodePage(String a_name,
|
||||
int a_osTwoFlag)
|
||||
{
|
||||
m_name = a_name;
|
||||
m_osTwoFlag = a_osTwoFlag;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
|
||||
public Charset getCharset() {
|
||||
return m_charset;
|
||||
}
|
||||
|
||||
public int getOsTwoFlag() {
|
||||
return m_osTwoFlag;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* $Id: TTCodePage.java,v 1.3 2004/05/16 12:59:07 eed3si9n Exp $
|
||||
*
|
||||
* $Copyright: copyright (c) 2003-2004, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.truetype;
|
||||
|
||||
import java.util.*;
|
||||
import java.nio.charset.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class TTCodePage {
|
||||
static public TTCodePage US_ASCII = new TTCodePage("US-ASCII",
|
||||
"US-ASCII",
|
||||
64);
|
||||
static public TTCodePage Latin_1 = new TTCodePage("windows-1252",
|
||||
"Latin 1 windows-1252",
|
||||
0);
|
||||
static private boolean s_isInitialized = false;
|
||||
static private ArrayList<TTCodePage> s_list = new ArrayList<>();
|
||||
|
||||
static public String [] getNames() {
|
||||
initList();
|
||||
String [] retval = new String[s_list.size()];
|
||||
int i;
|
||||
for (i = 0; i < s_list.size(); i++) {
|
||||
TTCodePage codePage = (TTCodePage) s_list.get(i);
|
||||
retval[i] = codePage.getName();
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static public TTCodePage forName(String a_name) {
|
||||
initList();
|
||||
|
||||
TTCodePage retval = null;
|
||||
for (TTCodePage codePage: s_list) {
|
||||
if (codePage.getName().equals(a_name)) {
|
||||
return codePage;
|
||||
}
|
||||
} // for
|
||||
|
||||
for (TTCodePage codePage: s_list) {
|
||||
if (codePage.getCharset() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (codePage.getCharset().name().equals(a_name)) {
|
||||
return codePage;
|
||||
}
|
||||
} // for
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static private void initList() {
|
||||
if (s_isInitialized)
|
||||
return;
|
||||
|
||||
s_isInitialized = true;
|
||||
|
||||
s_list.add(US_ASCII);
|
||||
s_list.add(Latin_1);
|
||||
s_list.add(new TTCodePage("ISO-2022-JP",
|
||||
"Japan-JIS",
|
||||
17));
|
||||
s_list.add(new TTCodePage("windows-1250",
|
||||
"Latin 2: Eastern Europe windows-1250",
|
||||
1));
|
||||
s_list.add(new TTCodePage("windows-1251",
|
||||
"Cyrillic windows-1251",
|
||||
2));
|
||||
s_list.add(new TTCodePage("windows-1253",
|
||||
"Greek windows-1253",
|
||||
3));
|
||||
s_list.add(new TTCodePage("windows-1254",
|
||||
"Turkish windows-1254",
|
||||
4));
|
||||
s_list.add(new TTCodePage("windows-1258",
|
||||
"Vietnamese windows-1258",
|
||||
8));
|
||||
|
||||
|
||||
// extended
|
||||
s_list.add(new TTCodePage("windows-1255",
|
||||
"Hebrew windows-1255",
|
||||
5));
|
||||
s_list.add(new TTCodePage("windows-1256",
|
||||
"Arabic windows-1256",
|
||||
6));
|
||||
s_list.add(new TTCodePage("windows-1257",
|
||||
"Windows Baltic",
|
||||
7));
|
||||
|
||||
// TODO: 16 Thai 874
|
||||
s_list.add(new TTCodePage(
|
||||
"Thai windows-874",
|
||||
16));
|
||||
|
||||
s_list.add(new TTCodePage("x-mswin-936",
|
||||
"Chinese: Simplified",
|
||||
18));
|
||||
|
||||
// TODO: 19 Korean Wansung
|
||||
s_list.add(new TTCodePage(
|
||||
"Korean Wansung",
|
||||
19));
|
||||
|
||||
s_list.add(new TTCodePage("x-windows-950",
|
||||
"Chinese: Traditional",
|
||||
20));
|
||||
}
|
||||
|
||||
|
||||
private String m_name;
|
||||
|
||||
/** http://www.microsoft.com/typography/otspec/os2.htm
|
||||
*/
|
||||
private int m_osTwoFlag = 0;
|
||||
private Charset m_charset = null;
|
||||
|
||||
public TTCodePage(String a_charsetName, String a_name,
|
||||
int a_osTwoFlag)
|
||||
{
|
||||
if (Charset.isSupported(a_charsetName)) {
|
||||
m_charset = Charset.forName(a_charsetName);
|
||||
}
|
||||
|
||||
m_name = a_name;
|
||||
m_osTwoFlag = a_osTwoFlag;
|
||||
}
|
||||
|
||||
public TTCodePage(String a_name,
|
||||
int a_osTwoFlag)
|
||||
{
|
||||
m_name = a_name;
|
||||
m_osTwoFlag = a_osTwoFlag;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
|
||||
public Charset getCharset() {
|
||||
return m_charset;
|
||||
}
|
||||
|
||||
public int getOsTwoFlag() {
|
||||
return m_osTwoFlag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,391 +1,391 @@
|
||||
/*
|
||||
* $Copyright: copyright (c) 2003-2008, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.truetype;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class TTGlyph {
|
||||
// --------------------------------------------------------------
|
||||
public static final int k_onCurve = 0x1;
|
||||
|
||||
public static final int ARG_1_AND_2_ARE_WORDS = 0x1;
|
||||
public static final int ARGS_ARE_XY_VALUES = 0x2;
|
||||
public static final int ROUND_XY_TO_GRID = 0x4;
|
||||
public static final int WE_HAVE_A_SCALE = 0x8;
|
||||
// 0x10 is obsolete
|
||||
public static final int MORE_COMPONENTS = 0x20;
|
||||
public static final int WE_HAVE_AN_X_AND_Y_SCALE = 0x40;
|
||||
public static final int WE_HAVE_A_TWO_BY_TWO = 0x80;
|
||||
public static final int WE_HAVE_INSTRUCTIONS = 0x100;
|
||||
public static final int USE_MY_METRICS = 0x200;
|
||||
public static final int OVERLAP_COMPOUND = 0x400;
|
||||
|
||||
/** Move Direct Absolute Point - do not round */
|
||||
public static final int MDAP0 = 0x2E;
|
||||
|
||||
/** Move Direct Absolute Point - round the value */
|
||||
public static final int MDAP1 = 0x2F;
|
||||
|
||||
/** Interpolate Untouched Points through the outline - y-direction */
|
||||
public static final int IUP0 = 0x30;
|
||||
|
||||
/** Interpolate Untouched Points through the outline - x-direction */
|
||||
public static final int IUP1 = 0x31;
|
||||
|
||||
/** push one byte */
|
||||
public static final int PUSHB000 = 0xB0;
|
||||
|
||||
/** push two bytes */
|
||||
public static final int PUSHB001 = 0xB1;
|
||||
|
||||
/** push three bytes */
|
||||
public static final int PUSHB010 = 0xB2;
|
||||
public static final int PUSHB011 = 0xB3;
|
||||
public static final int PUSHB100 = 0xB4;
|
||||
public static final int PUSHB101 = 0xB5;
|
||||
public static final int PUSHB110 = 0xB6;
|
||||
public static final int PUSHB111 = 0xB7;
|
||||
|
||||
/** set vector to y-axis. */
|
||||
public static final int SVTCA0 = 0x00;
|
||||
|
||||
/** set vector to x-axis. */
|
||||
public static final int SVTCA1 = 0x01;
|
||||
public static final int SPVFS = 0x0A; // set projection vector
|
||||
public static final int SFVFS = 0x0B; // set freedom vector
|
||||
public static final int SFVTPV = 0x0E;
|
||||
public static final int DELTAP1 = 0x5D;
|
||||
public static final int DELTAP2 = 0x71;
|
||||
public static final int DELTAP3 = 0x72;
|
||||
|
||||
/** set delta base */
|
||||
public static final int SDB = 0x5E;
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* converts double into F2Dot14, 16 bit fixed point format.
|
||||
* @param a_value
|
||||
* @return
|
||||
*/
|
||||
public static int toF2Dot14(double a_value) {
|
||||
int retval = 0;
|
||||
|
||||
if (a_value >= 2.0 || a_value < -2.0) {
|
||||
throw new RuntimeException(Double.toString(a_value) + " out of range");
|
||||
} // if
|
||||
|
||||
int mantissa = (int) Math.floor(a_value);
|
||||
int fraction = (int) Math.floor((a_value - mantissa) * 16384);
|
||||
|
||||
int twoBitPart = mantissa;
|
||||
if (mantissa < 0) {
|
||||
twoBitPart = 4 + mantissa;
|
||||
} // if
|
||||
|
||||
retval = (twoBitPart << 14) | fraction;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
public static int toDeltaArg(int a_relativePpem, int a_step) {
|
||||
int retval = 0;
|
||||
|
||||
if (a_step < -8 || a_step > 8 || a_step == 0) {
|
||||
throw new RuntimeException("Out of range");
|
||||
} // if
|
||||
|
||||
int selector = 0;
|
||||
if (a_step > 0) {
|
||||
selector = a_step + 7;
|
||||
} else {
|
||||
selector = a_step + 8;
|
||||
} // if
|
||||
|
||||
retval = (a_relativePpem << 4) | (selector);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
private ArrayList<Point> m_points = new ArrayList<>();
|
||||
private ArrayList<Integer> m_endPtsOfContours = new ArrayList<>();
|
||||
private ArrayList<Integer> m_instructions = new ArrayList<>();
|
||||
private ArrayList<Integer> m_flags = new ArrayList<>();
|
||||
private ArrayList<Integer> m_glyfIndeces = new ArrayList<>();
|
||||
private ArrayList<Integer> m_arg1s = new ArrayList<>();
|
||||
private ArrayList<Integer> m_arg2s = new ArrayList<>();
|
||||
|
||||
private boolean m_isSimple = true;
|
||||
private int m_advanceWidth = 512;
|
||||
|
||||
private int m_numOfCompositePoints = 0;
|
||||
private int m_numOfCompositeContours = 0;
|
||||
private int m_componentDepth = 0;
|
||||
|
||||
private Point m_min = null;
|
||||
private Point m_max = null;
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
public TTGlyph() {
|
||||
init();
|
||||
}
|
||||
|
||||
public void init() {
|
||||
m_isSimple = true;
|
||||
m_points.clear();
|
||||
m_endPtsOfContours.clear();
|
||||
m_instructions.clear();
|
||||
m_flags.clear();
|
||||
m_glyfIndeces.clear();
|
||||
m_arg1s.clear();
|
||||
m_arg2s.clear();
|
||||
m_advanceWidth = 512;
|
||||
}
|
||||
|
||||
public void buildCompound() {
|
||||
init();
|
||||
|
||||
m_isSimple = false;
|
||||
|
||||
addFlag(ARG_1_AND_2_ARE_WORDS
|
||||
| ARGS_ARE_XY_VALUES
|
||||
| ROUND_XY_TO_GRID
|
||||
| MORE_COMPONENTS);
|
||||
addFlag(ARG_1_AND_2_ARE_WORDS
|
||||
| ARGS_ARE_XY_VALUES
|
||||
| ROUND_XY_TO_GRID);
|
||||
|
||||
addGlyfIndex(3);
|
||||
addGlyfIndex(3);
|
||||
|
||||
addArg1(0);
|
||||
addArg2(0);
|
||||
addArg1(0);
|
||||
addArg2(500);
|
||||
}
|
||||
|
||||
/**
|
||||
* add the index of the last point in the contour
|
||||
* @param a_index
|
||||
*/
|
||||
public void addEndPoint(int a_value) {
|
||||
m_endPtsOfContours.add(a_value);
|
||||
}
|
||||
|
||||
public int getNumOfContours() {
|
||||
if (isSimple()) {
|
||||
return m_endPtsOfContours.size();
|
||||
} else {
|
||||
return -1;
|
||||
} // if-else
|
||||
}
|
||||
|
||||
public int getEndPoint(int a_index) {
|
||||
return m_endPtsOfContours.get(a_index);
|
||||
}
|
||||
|
||||
public int getAdvanceWidth() {
|
||||
return m_advanceWidth;
|
||||
}
|
||||
|
||||
public void setAdvanceWidth(int a_value) {
|
||||
m_advanceWidth = a_value;
|
||||
}
|
||||
|
||||
public Point getMax() {
|
||||
if (m_max == null) {
|
||||
m_max = new Point(0, 0);
|
||||
} // if
|
||||
|
||||
return m_max;
|
||||
}
|
||||
|
||||
public Point getMin() {
|
||||
if (m_min == null) {
|
||||
m_min = new Point(0, 0);
|
||||
} // if
|
||||
|
||||
return m_min;
|
||||
}
|
||||
|
||||
public boolean isSimple() {
|
||||
return m_isSimple;
|
||||
}
|
||||
|
||||
public void setSimple(boolean a_isSimple) {
|
||||
m_isSimple = a_isSimple;
|
||||
}
|
||||
|
||||
public void addInstruction(int a_value) {
|
||||
m_instructions.add(a_value);
|
||||
}
|
||||
|
||||
public int getInstruction(int a_index) {
|
||||
return m_instructions.get(a_index);
|
||||
}
|
||||
|
||||
public int getNumOfInstructions() {
|
||||
return m_instructions.size();
|
||||
}
|
||||
|
||||
public void addFlag(int a_value) {
|
||||
m_flags.add(a_value);
|
||||
}
|
||||
|
||||
public int getFlag(int a_index) {
|
||||
return m_flags.get(a_index);
|
||||
}
|
||||
|
||||
public int getNumOfFlags() {
|
||||
return m_flags.size();
|
||||
}
|
||||
|
||||
public void addPoint(Point a_value) {
|
||||
m_points.add(a_value);
|
||||
updateMinMax(a_value);
|
||||
}
|
||||
|
||||
private void updateMinMax(Point a_value) {
|
||||
if (m_max == null) {
|
||||
m_max = new Point(a_value);
|
||||
} // if
|
||||
|
||||
if (m_min == null) {
|
||||
m_min = new Point(a_value);
|
||||
} // if
|
||||
|
||||
if (a_value.x > m_max.x) {
|
||||
m_max.x = a_value.x;
|
||||
} // if
|
||||
|
||||
if (a_value.x < m_min.x) {
|
||||
m_min.x = a_value.x;
|
||||
} // if
|
||||
|
||||
if (a_value.y > m_max.y) {
|
||||
m_max.y = a_value.y;
|
||||
} // if
|
||||
|
||||
if (a_value.y < m_min.y) {
|
||||
m_min.y = a_value.y;
|
||||
} // if
|
||||
}
|
||||
|
||||
public Point getPoint(int a_index) {
|
||||
return m_points.get(a_index);
|
||||
}
|
||||
|
||||
public int getNumOfPoints() {
|
||||
return m_points.size();
|
||||
}
|
||||
|
||||
public int getLastIndex() {
|
||||
return m_points.size() - 1;
|
||||
}
|
||||
|
||||
public void addGlyfIndex(int a_value) {
|
||||
m_glyfIndeces.add(a_value);
|
||||
}
|
||||
|
||||
public int getGlyfIndex(int a_index) {
|
||||
return m_glyfIndeces.get(a_index);
|
||||
}
|
||||
|
||||
public void addArg1(int a_value) {
|
||||
m_arg1s.add(a_value);
|
||||
}
|
||||
|
||||
public int getArg1(int a_index) {
|
||||
return m_arg1s.get(a_index);
|
||||
}
|
||||
|
||||
public void addArg2(int a_value) {
|
||||
m_arg2s.add(a_value);
|
||||
}
|
||||
|
||||
public int getArg2(int a_index) {
|
||||
return m_arg2s.get(a_index);
|
||||
}
|
||||
|
||||
public int getNumOfCompositePoints() {
|
||||
if (isSimple()) {
|
||||
return getNumOfPoints();
|
||||
} else {
|
||||
return m_numOfCompositePoints;
|
||||
}
|
||||
}
|
||||
|
||||
public void setNumOfCompositePoints(int a_value) {
|
||||
m_numOfCompositePoints = a_value;
|
||||
}
|
||||
|
||||
public int getNumOfCompositeContours() {
|
||||
if (isSimple()) {
|
||||
return getNumOfContours();
|
||||
} else {
|
||||
return m_numOfCompositeContours;
|
||||
} // if-else
|
||||
}
|
||||
|
||||
public void setNumOfCompositeContours(int a_value) {
|
||||
m_numOfCompositeContours = a_value;
|
||||
}
|
||||
|
||||
public int getComponentDepth() {
|
||||
if (isSimple()) {
|
||||
return 0;
|
||||
} else {
|
||||
return m_componentDepth;
|
||||
} // if-else
|
||||
}
|
||||
|
||||
public void setComponentDepth(int a_value) {
|
||||
m_componentDepth = a_value;
|
||||
}
|
||||
|
||||
public int getLeftSideBearing() {
|
||||
return getMin().x;
|
||||
}
|
||||
|
||||
public int getRightSideBearing() {
|
||||
return getAdvanceWidth() - getMax().x;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* $Copyright: copyright (c) 2003-2008, e.e d3si9n $
|
||||
* $License:
|
||||
* This source code is part of DoubleType.
|
||||
* DoubleType is a graphical typeface designer.
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, e.e d3si9n gives permission to
|
||||
* link the code of this program with any Java Platform that is available
|
||||
* to public with free of charge, including but not limited to
|
||||
* Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE),
|
||||
* and distribute linked combinations including the two.
|
||||
* You must obey the GNU General Public License in all respects for all
|
||||
* of the code used other than Java Platform. If you modify this file,
|
||||
* you may extend this exception to your version of the file, but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version.
|
||||
* $
|
||||
*/
|
||||
|
||||
package org.doubletype.ossa.truetype;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author e.e
|
||||
*/
|
||||
public class TTGlyph {
|
||||
// --------------------------------------------------------------
|
||||
public static final int k_onCurve = 0x1;
|
||||
|
||||
public static final int ARG_1_AND_2_ARE_WORDS = 0x1;
|
||||
public static final int ARGS_ARE_XY_VALUES = 0x2;
|
||||
public static final int ROUND_XY_TO_GRID = 0x4;
|
||||
public static final int WE_HAVE_A_SCALE = 0x8;
|
||||
// 0x10 is obsolete
|
||||
public static final int MORE_COMPONENTS = 0x20;
|
||||
public static final int WE_HAVE_AN_X_AND_Y_SCALE = 0x40;
|
||||
public static final int WE_HAVE_A_TWO_BY_TWO = 0x80;
|
||||
public static final int WE_HAVE_INSTRUCTIONS = 0x100;
|
||||
public static final int USE_MY_METRICS = 0x200;
|
||||
public static final int OVERLAP_COMPOUND = 0x400;
|
||||
|
||||
/** Move Direct Absolute Point - do not round */
|
||||
public static final int MDAP0 = 0x2E;
|
||||
|
||||
/** Move Direct Absolute Point - round the value */
|
||||
public static final int MDAP1 = 0x2F;
|
||||
|
||||
/** Interpolate Untouched Points through the outline - y-direction */
|
||||
public static final int IUP0 = 0x30;
|
||||
|
||||
/** Interpolate Untouched Points through the outline - x-direction */
|
||||
public static final int IUP1 = 0x31;
|
||||
|
||||
/** push one byte */
|
||||
public static final int PUSHB000 = 0xB0;
|
||||
|
||||
/** push two bytes */
|
||||
public static final int PUSHB001 = 0xB1;
|
||||
|
||||
/** push three bytes */
|
||||
public static final int PUSHB010 = 0xB2;
|
||||
public static final int PUSHB011 = 0xB3;
|
||||
public static final int PUSHB100 = 0xB4;
|
||||
public static final int PUSHB101 = 0xB5;
|
||||
public static final int PUSHB110 = 0xB6;
|
||||
public static final int PUSHB111 = 0xB7;
|
||||
|
||||
/** set vector to y-axis. */
|
||||
public static final int SVTCA0 = 0x00;
|
||||
|
||||
/** set vector to x-axis. */
|
||||
public static final int SVTCA1 = 0x01;
|
||||
public static final int SPVFS = 0x0A; // set projection vector
|
||||
public static final int SFVFS = 0x0B; // set freedom vector
|
||||
public static final int SFVTPV = 0x0E;
|
||||
public static final int DELTAP1 = 0x5D;
|
||||
public static final int DELTAP2 = 0x71;
|
||||
public static final int DELTAP3 = 0x72;
|
||||
|
||||
/** set delta base */
|
||||
public static final int SDB = 0x5E;
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* converts double into F2Dot14, 16 bit fixed point format.
|
||||
* @param a_value
|
||||
* @return
|
||||
*/
|
||||
public static int toF2Dot14(double a_value) {
|
||||
int retval = 0;
|
||||
|
||||
if (a_value >= 2.0 || a_value < -2.0) {
|
||||
throw new RuntimeException(Double.toString(a_value) + " out of range");
|
||||
}
|
||||
|
||||
int mantissa = (int) Math.floor(a_value);
|
||||
int fraction = (int) Math.floor((a_value - mantissa) * 16384);
|
||||
|
||||
int twoBitPart = mantissa;
|
||||
if (mantissa < 0) {
|
||||
twoBitPart = 4 + mantissa;
|
||||
}
|
||||
|
||||
retval = (twoBitPart << 14) | fraction;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
public static int toDeltaArg(int a_relativePpem, int a_step) {
|
||||
int retval = 0;
|
||||
|
||||
if (a_step < -8 || a_step > 8 || a_step == 0) {
|
||||
throw new RuntimeException("Out of range");
|
||||
}
|
||||
|
||||
int selector = 0;
|
||||
if (a_step > 0) {
|
||||
selector = a_step + 7;
|
||||
} else {
|
||||
selector = a_step + 8;
|
||||
}
|
||||
|
||||
retval = (a_relativePpem << 4) | (selector);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
private ArrayList<Point> m_points = new ArrayList<>();
|
||||
private ArrayList<Integer> m_endPtsOfContours = new ArrayList<>();
|
||||
private ArrayList<Integer> m_instructions = new ArrayList<>();
|
||||
private ArrayList<Integer> m_flags = new ArrayList<>();
|
||||
private ArrayList<Integer> m_glyfIndeces = new ArrayList<>();
|
||||
private ArrayList<Integer> m_arg1s = new ArrayList<>();
|
||||
private ArrayList<Integer> m_arg2s = new ArrayList<>();
|
||||
|
||||
private boolean m_isSimple = true;
|
||||
private int m_advanceWidth = 512;
|
||||
|
||||
private int m_numOfCompositePoints = 0;
|
||||
private int m_numOfCompositeContours = 0;
|
||||
private int m_componentDepth = 0;
|
||||
|
||||
private Point m_min = null;
|
||||
private Point m_max = null;
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
public TTGlyph() {
|
||||
init();
|
||||
}
|
||||
|
||||
public void init() {
|
||||
m_isSimple = true;
|
||||
m_points.clear();
|
||||
m_endPtsOfContours.clear();
|
||||
m_instructions.clear();
|
||||
m_flags.clear();
|
||||
m_glyfIndeces.clear();
|
||||
m_arg1s.clear();
|
||||
m_arg2s.clear();
|
||||
m_advanceWidth = 512;
|
||||
}
|
||||
|
||||
public void buildCompound() {
|
||||
init();
|
||||
|
||||
m_isSimple = false;
|
||||
|
||||
addFlag(ARG_1_AND_2_ARE_WORDS
|
||||
| ARGS_ARE_XY_VALUES
|
||||
| ROUND_XY_TO_GRID
|
||||
| MORE_COMPONENTS);
|
||||
addFlag(ARG_1_AND_2_ARE_WORDS
|
||||
| ARGS_ARE_XY_VALUES
|
||||
| ROUND_XY_TO_GRID);
|
||||
|
||||
addGlyfIndex(3);
|
||||
addGlyfIndex(3);
|
||||
|
||||
addArg1(0);
|
||||
addArg2(0);
|
||||
addArg1(0);
|
||||
addArg2(500);
|
||||
}
|
||||
|
||||
/**
|
||||
* add the index of the last point in the contour
|
||||
* @param a_index
|
||||
*/
|
||||
public void addEndPoint(int a_value) {
|
||||
m_endPtsOfContours.add(a_value);
|
||||
}
|
||||
|
||||
public int getNumOfContours() {
|
||||
if (isSimple()) {
|
||||
return m_endPtsOfContours.size();
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public int getEndPoint(int a_index) {
|
||||
return m_endPtsOfContours.get(a_index);
|
||||
}
|
||||
|
||||
public int getAdvanceWidth() {
|
||||
return m_advanceWidth;
|
||||
}
|
||||
|
||||
public void setAdvanceWidth(int a_value) {
|
||||
m_advanceWidth = a_value;
|
||||
}
|
||||
|
||||
public Point getMax() {
|
||||
if (m_max == null) {
|
||||
m_max = new Point(0, 0);
|
||||
}
|
||||
|
||||
return m_max;
|
||||
}
|
||||
|
||||
public Point getMin() {
|
||||
if (m_min == null) {
|
||||
m_min = new Point(0, 0);
|
||||
}
|
||||
|
||||
return m_min;
|
||||
}
|
||||
|
||||
public boolean isSimple() {
|
||||
return m_isSimple;
|
||||
}
|
||||
|
||||
public void setSimple(boolean a_isSimple) {
|
||||
m_isSimple = a_isSimple;
|
||||
}
|
||||
|
||||
public void addInstruction(int a_value) {
|
||||
m_instructions.add(a_value);
|
||||
}
|
||||
|
||||
public int getInstruction(int a_index) {
|
||||
return m_instructions.get(a_index);
|
||||
}
|
||||
|
||||
public int getNumOfInstructions() {
|
||||
return m_instructions.size();
|
||||
}
|
||||
|
||||
public void addFlag(int a_value) {
|
||||
m_flags.add(a_value);
|
||||
}
|
||||
|
||||
public int getFlag(int a_index) {
|
||||
return m_flags.get(a_index);
|
||||
}
|
||||
|
||||
public int getNumOfFlags() {
|
||||
return m_flags.size();
|
||||
}
|
||||
|
||||
public void addPoint(Point a_value) {
|
||||
m_points.add(a_value);
|
||||
updateMinMax(a_value);
|
||||
}
|
||||
|
||||
private void updateMinMax(Point a_value) {
|
||||
if (m_max == null) {
|
||||
m_max = new Point(a_value);
|
||||
}
|
||||
|
||||
if (m_min == null) {
|
||||
m_min = new Point(a_value);
|
||||
}
|
||||
|
||||
if (a_value.x > m_max.x) {
|
||||
m_max.x = a_value.x;
|
||||
}
|
||||
|
||||
if (a_value.x < m_min.x) {
|
||||
m_min.x = a_value.x;
|
||||
}
|
||||
|
||||
if (a_value.y > m_max.y) {
|
||||
m_max.y = a_value.y;
|
||||
}
|
||||
|
||||
if (a_value.y < m_min.y) {
|
||||
m_min.y = a_value.y;
|
||||
}
|
||||
}
|
||||
|
||||
public Point getPoint(int a_index) {
|
||||
return m_points.get(a_index);
|
||||
}
|
||||
|
||||
public int getNumOfPoints() {
|
||||
return m_points.size();
|
||||
}
|
||||
|
||||
public int getLastIndex() {
|
||||
return m_points.size() - 1;
|
||||
}
|
||||
|
||||
public void addGlyfIndex(int a_value) {
|
||||
m_glyfIndeces.add(a_value);
|
||||
}
|
||||
|
||||
public int getGlyfIndex(int a_index) {
|
||||
return m_glyfIndeces.get(a_index);
|
||||
}
|
||||
|
||||
public void addArg1(int a_value) {
|
||||
m_arg1s.add(a_value);
|
||||
}
|
||||
|
||||
public int getArg1(int a_index) {
|
||||
return m_arg1s.get(a_index);
|
||||
}
|
||||
|
||||
public void addArg2(int a_value) {
|
||||
m_arg2s.add(a_value);
|
||||
}
|
||||
|
||||
public int getArg2(int a_index) {
|
||||
return m_arg2s.get(a_index);
|
||||
}
|
||||
|
||||
public int getNumOfCompositePoints() {
|
||||
if (isSimple()) {
|
||||
return getNumOfPoints();
|
||||
} else {
|
||||
return m_numOfCompositePoints;
|
||||
}
|
||||
}
|
||||
|
||||
public void setNumOfCompositePoints(int a_value) {
|
||||
m_numOfCompositePoints = a_value;
|
||||
}
|
||||
|
||||
public int getNumOfCompositeContours() {
|
||||
if (isSimple()) {
|
||||
return getNumOfContours();
|
||||
} else {
|
||||
return m_numOfCompositeContours;
|
||||
}
|
||||
}
|
||||
|
||||
public void setNumOfCompositeContours(int a_value) {
|
||||
m_numOfCompositeContours = a_value;
|
||||
}
|
||||
|
||||
public int getComponentDepth() {
|
||||
if (isSimple()) {
|
||||
return 0;
|
||||
} else {
|
||||
return m_componentDepth;
|
||||
}
|
||||
}
|
||||
|
||||
public void setComponentDepth(int a_value) {
|
||||
m_componentDepth = a_value;
|
||||
}
|
||||
|
||||
public int getLeftSideBearing() {
|
||||
return getMin().x;
|
||||
}
|
||||
|
||||
public int getRightSideBearing() {
|
||||
return getAdvanceWidth() - getMax().x;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,107 +1,107 @@
|
||||
package org.doubletype.ossa.truetype;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TTPixelSize {
|
||||
static private int s_em = 1024;
|
||||
static private boolean s_isInitialized = false;
|
||||
static private ArrayList<TTPixelSize> s_list = new ArrayList<>();
|
||||
|
||||
static public int getEm() {
|
||||
return s_em;
|
||||
}
|
||||
|
||||
static public ArrayList<TTPixelSize> getList() {
|
||||
initList();
|
||||
return s_list;
|
||||
}
|
||||
|
||||
static private void initList() {
|
||||
if (s_isInitialized)
|
||||
return;
|
||||
|
||||
s_isInitialized = true;
|
||||
|
||||
// s_list.add(new TTPixelSize(9, "9px: 7pt(96dpi)/9pt(72dpi)"));
|
||||
// s_list.add(new TTPixelSize(10, "10px: 7.5pt(96dpi)/10pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(11, "11px: 8pt(96dpi)/11pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(12, "12px: 9pt(96dpi)/12pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(13, "13px: 10pt(96dpi)/13pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(14, "14px: 10.5pt(96dpi)/14pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(15, "15px: 11pt(96dpi)/15pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(16, "16px: 12pt(96dpi)/16pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(17, "17px: 13pt(96dpi)/17pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(18, "18px: 13.5pt(96dpi)/18pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(19, "19px: 14pt(96dpi)/14pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(20, "20px: 15pt(96dpi)/20pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(21, "21px: 16pt(96dpi)/21pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(22, "22px: 16.5pt(96dpi)/22pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(23, "23px: 17pt(96dpi)/23pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(24, "24px: 18pt(96dpi)/24pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(27, "27px: 20pt(96dpi)"));
|
||||
s_list.add(new TTPixelSize(29, "29px: 22pt(96dpi)"));
|
||||
s_list.add(new TTPixelSize(32, "32px: 24pt(96dpi)"));
|
||||
s_list.add(new TTPixelSize(33, "33px: 8pt(300dpi) "));
|
||||
// s_list.add(new TTPixelSize(35, "35px: 26pt(96dpi) "));
|
||||
s_list.add(new TTPixelSize(37, "37px: 28pt(96dpi)"));
|
||||
// s_list.add(new TTPixelSize(38, "38px: 9pt(300dpi)");
|
||||
s_list.add(new TTPixelSize(42, "42px: 10pt(300dpi)"));
|
||||
// s_list.add(new TTPixelSize(44, "44px: 10.5pt(300dpi)"));
|
||||
s_list.add(new TTPixelSize(46, "46px: 11pt(300dpi)"));
|
||||
s_list.add(new TTPixelSize(50, "50px: 12pt(300dpi)"));
|
||||
s_list.add(new TTPixelSize(54, "54px: 13pt(300dpi)"));
|
||||
s_list.add(new TTPixelSize(58, "58px: 14pt(300dpi)"));
|
||||
s_list.add(new TTPixelSize(67, "67px: 16pt(300dpi)"));
|
||||
s_list.add(new TTPixelSize(75, "75px: 18pt(300dpi)"));
|
||||
s_list.add(new TTPixelSize(83, "83px: 20pt(300dpi)"));
|
||||
s_list.add(new TTPixelSize(92, "92px: 22pt(300dpi)"));
|
||||
s_list.add(new TTPixelSize(100, "100px: 24pt(300dpi)"));
|
||||
}
|
||||
|
||||
private int m_pixel;
|
||||
private String m_description;
|
||||
private int m_pixelWidths[];
|
||||
private int m_maxPixelWidth = 0;
|
||||
|
||||
public TTPixelSize(int a_pixel, String a_description)
|
||||
{
|
||||
m_pixel = a_pixel;
|
||||
m_description = a_description;
|
||||
}
|
||||
|
||||
public int getPixel() {
|
||||
return m_pixel;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return m_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the size of the pixel widths. Use num of glyphs.
|
||||
* @param a_size
|
||||
*/
|
||||
public void setPixelWidthsSize(int a_size) {
|
||||
m_pixelWidths = new int[a_size];
|
||||
m_maxPixelWidth = 0;
|
||||
}
|
||||
|
||||
public void setPixelWidth(int a_glyphIndex, int a_value) {
|
||||
m_pixelWidths[a_glyphIndex] = a_value;
|
||||
if (a_value > m_maxPixelWidth) {
|
||||
m_maxPixelWidth = a_value;
|
||||
} // if
|
||||
}
|
||||
|
||||
public int [] getPixelWidths() {
|
||||
return m_pixelWidths;
|
||||
}
|
||||
|
||||
public int getPixelWidth(int a_glyphIndex) {
|
||||
return m_pixelWidths[a_glyphIndex];
|
||||
}
|
||||
|
||||
public int getMaxPixelWidth() {
|
||||
return m_maxPixelWidth;
|
||||
}
|
||||
}
|
||||
package org.doubletype.ossa.truetype;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TTPixelSize {
|
||||
static private int s_em = 1024;
|
||||
static private boolean s_isInitialized = false;
|
||||
static private ArrayList<TTPixelSize> s_list = new ArrayList<>();
|
||||
|
||||
static public int getEm() {
|
||||
return s_em;
|
||||
}
|
||||
|
||||
static public ArrayList<TTPixelSize> getList() {
|
||||
initList();
|
||||
return s_list;
|
||||
}
|
||||
|
||||
static private void initList() {
|
||||
if (s_isInitialized)
|
||||
return;
|
||||
|
||||
s_isInitialized = true;
|
||||
|
||||
// s_list.add(new TTPixelSize(9, "9px: 7pt(96dpi)/9pt(72dpi)"));
|
||||
// s_list.add(new TTPixelSize(10, "10px: 7.5pt(96dpi)/10pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(11, "11px: 8pt(96dpi)/11pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(12, "12px: 9pt(96dpi)/12pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(13, "13px: 10pt(96dpi)/13pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(14, "14px: 10.5pt(96dpi)/14pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(15, "15px: 11pt(96dpi)/15pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(16, "16px: 12pt(96dpi)/16pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(17, "17px: 13pt(96dpi)/17pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(18, "18px: 13.5pt(96dpi)/18pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(19, "19px: 14pt(96dpi)/14pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(20, "20px: 15pt(96dpi)/20pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(21, "21px: 16pt(96dpi)/21pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(22, "22px: 16.5pt(96dpi)/22pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(23, "23px: 17pt(96dpi)/23pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(24, "24px: 18pt(96dpi)/24pt(72dpi)"));
|
||||
s_list.add(new TTPixelSize(27, "27px: 20pt(96dpi)"));
|
||||
s_list.add(new TTPixelSize(29, "29px: 22pt(96dpi)"));
|
||||
s_list.add(new TTPixelSize(32, "32px: 24pt(96dpi)"));
|
||||
s_list.add(new TTPixelSize(33, "33px: 8pt(300dpi) "));
|
||||
// s_list.add(new TTPixelSize(35, "35px: 26pt(96dpi) "));
|
||||
s_list.add(new TTPixelSize(37, "37px: 28pt(96dpi)"));
|
||||
// s_list.add(new TTPixelSize(38, "38px: 9pt(300dpi)");
|
||||
s_list.add(new TTPixelSize(42, "42px: 10pt(300dpi)"));
|
||||
// s_list.add(new TTPixelSize(44, "44px: 10.5pt(300dpi)"));
|
||||
s_list.add(new TTPixelSize(46, "46px: 11pt(300dpi)"));
|
||||
s_list.add(new TTPixelSize(50, "50px: 12pt(300dpi)"));
|
||||
s_list.add(new TTPixelSize(54, "54px: 13pt(300dpi)"));
|
||||
s_list.add(new TTPixelSize(58, "58px: 14pt(300dpi)"));
|
||||
s_list.add(new TTPixelSize(67, "67px: 16pt(300dpi)"));
|
||||
s_list.add(new TTPixelSize(75, "75px: 18pt(300dpi)"));
|
||||
s_list.add(new TTPixelSize(83, "83px: 20pt(300dpi)"));
|
||||
s_list.add(new TTPixelSize(92, "92px: 22pt(300dpi)"));
|
||||
s_list.add(new TTPixelSize(100, "100px: 24pt(300dpi)"));
|
||||
}
|
||||
|
||||
private int m_pixel;
|
||||
private String m_description;
|
||||
private int m_pixelWidths[];
|
||||
private int m_maxPixelWidth = 0;
|
||||
|
||||
public TTPixelSize(int a_pixel, String a_description)
|
||||
{
|
||||
m_pixel = a_pixel;
|
||||
m_description = a_description;
|
||||
}
|
||||
|
||||
public int getPixel() {
|
||||
return m_pixel;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return m_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the size of the pixel widths. Use num of glyphs.
|
||||
* @param a_size
|
||||
*/
|
||||
public void setPixelWidthsSize(int a_size) {
|
||||
m_pixelWidths = new int[a_size];
|
||||
m_maxPixelWidth = 0;
|
||||
}
|
||||
|
||||
public void setPixelWidth(int a_glyphIndex, int a_value) {
|
||||
m_pixelWidths[a_glyphIndex] = a_value;
|
||||
if (a_value > m_maxPixelWidth) {
|
||||
m_maxPixelWidth = a_value;
|
||||
}
|
||||
}
|
||||
|
||||
public int [] getPixelWidths() {
|
||||
return m_pixelWidths;
|
||||
}
|
||||
|
||||
public int getPixelWidth(int a_glyphIndex) {
|
||||
return m_pixelWidths[a_glyphIndex];
|
||||
}
|
||||
|
||||
public int getMaxPixelWidth() {
|
||||
return m_maxPixelWidth;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,8 +65,8 @@ public class TTUnicodeRange implements Comparable<TTUnicodeRange> {
|
||||
TTUnicodeRange range = s_list.get(i);
|
||||
if (range.m_block.equals(block)) {
|
||||
return range;
|
||||
} // if
|
||||
} // for i
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -300,8 +300,8 @@ public class TTUnicodeRange implements Comparable<TTUnicodeRange> {
|
||||
s_selected = range;
|
||||
|
||||
return true;
|
||||
} // if
|
||||
} // for i
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,394 +0,0 @@
|
||||
/*
|
||||
* The Relaxer artifact
|
||||
* Copyright (c) 2000-2004, ASAMI Tomoharu, All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.doubletype.ossa.xml;
|
||||
|
||||
/**
|
||||
* DefaultGlyphFactory is generated by Relaxer based on glyph.rng.
|
||||
*
|
||||
* @version glyph.rng 1.0 (Tue Nov 09 20:22:48 EST 2004)
|
||||
* @author Relaxer 1.1b (http://www.relaxer.org)
|
||||
*/
|
||||
public class DefaultGlyphFactory extends AbstractGlyphFactory {
|
||||
|
||||
/**
|
||||
* Gets a Class of <code>XParamListParam</code>.
|
||||
*
|
||||
* @return Class
|
||||
*/
|
||||
public Class getXParamListParamClass() {
|
||||
return (XParamListParam.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Class of <code>XHeadGlobal</code>.
|
||||
*
|
||||
* @return Class
|
||||
*/
|
||||
public Class getXHeadGlobalClass() {
|
||||
return (XHeadGlobal.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Class of <code>XHeadLocal</code>.
|
||||
*
|
||||
* @return Class
|
||||
*/
|
||||
public Class getXHeadLocalClass() {
|
||||
return (XHeadLocal.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Class of <code>XHead</code>.
|
||||
*
|
||||
* @return Class
|
||||
*/
|
||||
public Class getXHeadClass() {
|
||||
return (XHead.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Class of <code>XGlyphFile</code>.
|
||||
*
|
||||
* @return Class
|
||||
*/
|
||||
public Class getXGlyphFileClass() {
|
||||
return (XGlyphFile.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Class of <code>XContour</code>.
|
||||
*
|
||||
* @return Class
|
||||
*/
|
||||
public Class getXContourClass() {
|
||||
return (XContour.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Class of <code>XPoint2d</code>.
|
||||
*
|
||||
* @return Class
|
||||
*/
|
||||
public Class getXPoint2dClass() {
|
||||
return (XPoint2d.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Class of <code>XInvokePos</code>.
|
||||
*
|
||||
* @return Class
|
||||
*/
|
||||
public Class getXInvokePosClass() {
|
||||
return (XInvokePos.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Class of <code>XInvokeArg</code>.
|
||||
*
|
||||
* @return Class
|
||||
*/
|
||||
public Class getXInvokeArgClass() {
|
||||
return (XInvokeArg.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Class of <code>XInvokeVarg</code>.
|
||||
*
|
||||
* @return Class
|
||||
*/
|
||||
public Class getXInvokeVargClass() {
|
||||
return (XInvokeVarg.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Class of <code>XInvoke</code>.
|
||||
*
|
||||
* @return Class
|
||||
*/
|
||||
public Class getXInvokeClass() {
|
||||
return (XInvoke.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Class of <code>XInclude</code>.
|
||||
*
|
||||
* @return Class
|
||||
*/
|
||||
public Class getXIncludeClass() {
|
||||
return (XInclude.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Class of <code>XModule</code>.
|
||||
*
|
||||
* @return Class
|
||||
*/
|
||||
public Class getXModuleClass() {
|
||||
return (XModule.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Class of <code>XBody</code>.
|
||||
*
|
||||
* @return Class
|
||||
*/
|
||||
public Class getXBodyClass() {
|
||||
return (XBody.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Class of <code>XStartGlyphElement</code>.
|
||||
*
|
||||
* @return Class
|
||||
*/
|
||||
public Class getXStartGlyphElementClass() {
|
||||
return (XStartGlyphElement.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Class of <code>XControlPoint</code>.
|
||||
*
|
||||
* @return Class
|
||||
*/
|
||||
public Class getXControlPointClass() {
|
||||
return (XControlPoint.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Class of <code>XHint</code>.
|
||||
*
|
||||
* @return Class
|
||||
*/
|
||||
public Class getXHintClass() {
|
||||
return (XHint.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Class of <code>XContourPoint</code>.
|
||||
*
|
||||
* @return Class
|
||||
*/
|
||||
public Class getXContourPointClass() {
|
||||
return (XContourPoint.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Class of <code>XParamList</code>.
|
||||
*
|
||||
* @return Class
|
||||
*/
|
||||
public Class getXParamListClass() {
|
||||
return (XParamList.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a default <code>XParamListParam</code>.
|
||||
* This method is a hook method of the AbstractGlyphFactory.
|
||||
*
|
||||
* @return XParamListParam
|
||||
*/
|
||||
public XParamListParam createXParamListParam() {
|
||||
return (new XParamListParam());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a default <code>XHeadGlobal</code>.
|
||||
* This method is a hook method of the AbstractGlyphFactory.
|
||||
*
|
||||
* @return XHeadGlobal
|
||||
*/
|
||||
public XHeadGlobal createXHeadGlobal() {
|
||||
return (new XHeadGlobal());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a default <code>XHeadLocal</code>.
|
||||
* This method is a hook method of the AbstractGlyphFactory.
|
||||
*
|
||||
* @return XHeadLocal
|
||||
*/
|
||||
public XHeadLocal createXHeadLocal() {
|
||||
return (new XHeadLocal());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a default <code>XHead</code>.
|
||||
* This method is a hook method of the AbstractGlyphFactory.
|
||||
*
|
||||
* @return XHead
|
||||
*/
|
||||
public XHead createXHead() {
|
||||
return (new XHead());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a default <code>XGlyphFile</code>.
|
||||
* This method is a hook method of the AbstractGlyphFactory.
|
||||
*
|
||||
* @return XGlyphFile
|
||||
*/
|
||||
public XGlyphFile createXGlyphFile() {
|
||||
return (new XGlyphFile());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a default <code>XContour</code>.
|
||||
* This method is a hook method of the AbstractGlyphFactory.
|
||||
*
|
||||
* @return XContour
|
||||
*/
|
||||
public XContour createXContour() {
|
||||
return (new XContour());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a default <code>XPoint2d</code>.
|
||||
* This method is a hook method of the AbstractGlyphFactory.
|
||||
*
|
||||
* @return XPoint2d
|
||||
*/
|
||||
public XPoint2d createXPoint2d() {
|
||||
return (new XPoint2d());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a default <code>XInvokePos</code>.
|
||||
* This method is a hook method of the AbstractGlyphFactory.
|
||||
*
|
||||
* @return XInvokePos
|
||||
*/
|
||||
public XInvokePos createXInvokePos() {
|
||||
return (new XInvokePos());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a default <code>XInvokeArg</code>.
|
||||
* This method is a hook method of the AbstractGlyphFactory.
|
||||
*
|
||||
* @return XInvokeArg
|
||||
*/
|
||||
public XInvokeArg createXInvokeArg() {
|
||||
return (new XInvokeArg());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a default <code>XInvokeVarg</code>.
|
||||
* This method is a hook method of the AbstractGlyphFactory.
|
||||
*
|
||||
* @return XInvokeVarg
|
||||
*/
|
||||
public XInvokeVarg createXInvokeVarg() {
|
||||
return (new XInvokeVarg());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a default <code>XInvoke</code>.
|
||||
* This method is a hook method of the AbstractGlyphFactory.
|
||||
*
|
||||
* @return XInvoke
|
||||
*/
|
||||
public XInvoke createXInvoke() {
|
||||
return (new XInvoke());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a default <code>XInclude</code>.
|
||||
* This method is a hook method of the AbstractGlyphFactory.
|
||||
*
|
||||
* @return XInclude
|
||||
*/
|
||||
public XInclude createXInclude() {
|
||||
return (new XInclude());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a default <code>XModule</code>.
|
||||
* This method is a hook method of the AbstractGlyphFactory.
|
||||
*
|
||||
* @return XModule
|
||||
*/
|
||||
public XModule createXModule() {
|
||||
return (new XModule());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a default <code>XBody</code>.
|
||||
* This method is a hook method of the AbstractGlyphFactory.
|
||||
*
|
||||
* @return XBody
|
||||
*/
|
||||
public XBody createXBody() {
|
||||
return (new XBody());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a default <code>XStartGlyphElement</code>.
|
||||
* This method is a hook method of the AbstractGlyphFactory.
|
||||
*
|
||||
* @return XStartGlyphElement
|
||||
*/
|
||||
public XStartGlyphElement createXStartGlyphElement() {
|
||||
return (new XStartGlyphElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a default <code>XControlPoint</code>.
|
||||
* This method is a hook method of the AbstractGlyphFactory.
|
||||
*
|
||||
* @return XControlPoint
|
||||
*/
|
||||
public XControlPoint createXControlPoint() {
|
||||
return (new XControlPoint());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a default <code>XHint</code>.
|
||||
* This method is a hook method of the AbstractGlyphFactory.
|
||||
*
|
||||
* @return XHint
|
||||
*/
|
||||
public XHint createXHint() {
|
||||
return (new XHint());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a default <code>XContourPoint</code>.
|
||||
* This method is a hook method of the AbstractGlyphFactory.
|
||||
*
|
||||
* @return XContourPoint
|
||||
*/
|
||||
public XContourPoint createXContourPoint() {
|
||||
return (new XContourPoint());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a default <code>XParamList</code>.
|
||||
* This method is a hook method of the AbstractGlyphFactory.
|
||||
*
|
||||
* @return XParamList
|
||||
*/
|
||||
public XParamList createXParamList() {
|
||||
return (new XParamList());
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* The Relaxer artifact
|
||||
* Copyright (c) 2000-2004, ASAMI Tomoharu, All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.doubletype.ossa.xml;
|
||||
|
||||
/**
|
||||
* GlyphFactory is generated by Relaxer based on glyph.rng.
|
||||
*
|
||||
* @version glyph.rng 1.0 (Tue Nov 09 20:22:48 EST 2004)
|
||||
* @author Relaxer 1.1b (http://www.relaxer.org)
|
||||
*/
|
||||
public class GlyphFactory {
|
||||
private static IGlyphFactory factory;
|
||||
|
||||
/**
|
||||
* Sets a factory.
|
||||
*
|
||||
* @param newFactory
|
||||
*/
|
||||
public static void setFactory(IGlyphFactory newFactory) {
|
||||
factory = newFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the factory.
|
||||
*
|
||||
* @return IGlyphFactory
|
||||
*/
|
||||
public static IGlyphFactory getFactory() {
|
||||
if (factory == null) {
|
||||
factory = new DefaultGlyphFactory();
|
||||
}
|
||||
return (factory);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* The Relaxer artifact
|
||||
* Copyright (c) 2000-2004, ASAMI Tomoharu, All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.doubletype.ossa.xml;
|
||||
|
||||
/**
|
||||
* @version glyph.rng 1.0 (Tue Nov 09 20:22:48 EST 2004)
|
||||
* @author Relaxer 1.1b (http://www.relaxer.org)
|
||||
*/
|
||||
public interface IRNode {
|
||||
/**
|
||||
* Sets parent RNode.
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
void rSetParentRNode(IRNode parent);
|
||||
|
||||
/**
|
||||
* Gets parent RNode.
|
||||
*
|
||||
* @return IRNode
|
||||
*/
|
||||
IRNode rGetParentRNode();
|
||||
|
||||
/**
|
||||
* Gets child RNodes.
|
||||
*
|
||||
* @return IRNode[]
|
||||
*/
|
||||
IRNode[] rGetRNodes();
|
||||
}
|
||||
@@ -1,753 +0,0 @@
|
||||
/*
|
||||
* The Relaxer artifact
|
||||
* Copyright (c) 2000-2004, ASAMI Tomoharu, All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.doubletype.ossa.xml;
|
||||
|
||||
import java.util.*;
|
||||
import java.net.URL;
|
||||
import java.math.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.sql.Time;
|
||||
import java.sql.Timestamp;
|
||||
import org.w3c.dom.*;
|
||||
|
||||
/**
|
||||
* RInterleave
|
||||
*
|
||||
* @since May. 13, 2002
|
||||
* @version Oct. 22, 2003
|
||||
* @author ASAMI, Tomoharu (asami@relaxer.org)
|
||||
*/
|
||||
public final class RInterleave {
|
||||
private RStack rstack_;
|
||||
private List<Entry> entries_ = new ArrayList<>();
|
||||
private Map<Class,Entry> entryByStateClass_ = new HashMap<>();
|
||||
private Map<String,Entry> entryByElementName_ = new HashMap<>();
|
||||
private Boolean isMatch_ = null;
|
||||
|
||||
public RInterleave(RStack rstack) {
|
||||
rstack_ = rstack;
|
||||
}
|
||||
|
||||
public Object getProperty(Class stateClass) {
|
||||
StateClassEntry entry = _getEntryByStateClass(stateClass);
|
||||
return (entry.getObject());
|
||||
}
|
||||
|
||||
public Object[] getPropertyList(Class stateClass) {
|
||||
StateClassEntry entry = _getEntryByStateClass(stateClass);
|
||||
return (entry.getObjects());
|
||||
}
|
||||
|
||||
public String getElementPropertyAsString(String elementName) {
|
||||
Element element = _getElementByElementName(elementName);
|
||||
if (element == null) {
|
||||
return (null);
|
||||
}
|
||||
return (URelaxer.getElementPropertyAsString(element));
|
||||
}
|
||||
|
||||
public boolean getElementPropertyAsBoolean(String elementName) {
|
||||
Element element = _getElementByElementName(elementName);
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
return (URelaxer.getElementPropertyAsBoolean(element));
|
||||
}
|
||||
|
||||
public Boolean getElementPropertyAsBooleanObject(String elementName) {
|
||||
Element element = _getElementByElementName(elementName);
|
||||
if (element == null) {
|
||||
return (null);
|
||||
}
|
||||
return (URelaxer.getElementPropertyAsBooleanObject(element));
|
||||
}
|
||||
|
||||
public byte getElementPropertyAsByte(String elementName) {
|
||||
Element element = _getElementByElementName(elementName);
|
||||
if (element == null) {
|
||||
return (-1);
|
||||
}
|
||||
return (URelaxer.getElementPropertyAsByte(element));
|
||||
}
|
||||
|
||||
public Byte getElementPropertyAsByteObject(String elementName) {
|
||||
Element element = _getElementByElementName(elementName);
|
||||
if (element == null) {
|
||||
return (null);
|
||||
}
|
||||
return (URelaxer.getElementPropertyAsByteObject(element));
|
||||
}
|
||||
|
||||
public short getElementPropertyAsShort(String elementName) {
|
||||
Element element = _getElementByElementName(elementName);
|
||||
if (element == null) {
|
||||
return (-1);
|
||||
}
|
||||
return (URelaxer.getElementPropertyAsShort(element));
|
||||
}
|
||||
|
||||
public Short getElementPropertyAsShortObject(String elementName) {
|
||||
Element element = _getElementByElementName(elementName);
|
||||
if (element == null) {
|
||||
return (null);
|
||||
}
|
||||
return (URelaxer.getElementPropertyAsShortObject(element));
|
||||
}
|
||||
|
||||
public int getElementPropertyAsInt(String elementName) {
|
||||
Element element = _getElementByElementName(elementName);
|
||||
if (element == null) {
|
||||
return (-1);
|
||||
}
|
||||
return (URelaxer.getElementPropertyAsInt(element));
|
||||
}
|
||||
|
||||
public Integer getElementPropertyAsIntObject(String elementName) {
|
||||
Element element = _getElementByElementName(elementName);
|
||||
if (element == null) {
|
||||
return (null);
|
||||
}
|
||||
return (URelaxer.getElementPropertyAsIntObject(element));
|
||||
}
|
||||
|
||||
public long getElementPropertyAsLong(String elementName) {
|
||||
Element element = _getElementByElementName(elementName);
|
||||
if (element == null) {
|
||||
return (-1);
|
||||
}
|
||||
return (URelaxer.getElementPropertyAsLong(element));
|
||||
}
|
||||
|
||||
public Long getElementPropertyAsLongObject(String elementName) {
|
||||
Element element = _getElementByElementName(elementName);
|
||||
if (element == null) {
|
||||
return (null);
|
||||
}
|
||||
return (URelaxer.getElementPropertyAsLongObject(element));
|
||||
}
|
||||
|
||||
public float getElementPropertyAsFloat(String elementName) {
|
||||
Element element = _getElementByElementName(elementName);
|
||||
if (element == null) {
|
||||
return (Float.NaN);
|
||||
}
|
||||
return (URelaxer.getElementPropertyAsFloat(element));
|
||||
}
|
||||
|
||||
public Float getElementPropertyAsFloatObject(String elementName) {
|
||||
Element element = _getElementByElementName(elementName);
|
||||
if (element == null) {
|
||||
return (null);
|
||||
}
|
||||
return (URelaxer.getElementPropertyAsFloatObject(element));
|
||||
}
|
||||
|
||||
public double getElementPropertyAsDouble(String elementName) {
|
||||
Element element = _getElementByElementName(elementName);
|
||||
if (element == null) {
|
||||
return (Double.NaN);
|
||||
}
|
||||
return (URelaxer.getElementPropertyAsDouble(element));
|
||||
}
|
||||
|
||||
public Double getElementPropertyAsDoubleObject(String elementName) {
|
||||
Element element = _getElementByElementName(elementName);
|
||||
if (element == null) {
|
||||
return (null);
|
||||
}
|
||||
return (URelaxer.getElementPropertyAsDoubleObject(element));
|
||||
}
|
||||
|
||||
public BigDecimal getElementPropertyAsBigDecimal(String elementName) {
|
||||
Element element = _getElementByElementName(elementName);
|
||||
if (element == null) {
|
||||
return (null);
|
||||
}
|
||||
return (URelaxer.getElementPropertyAsBigDecimal(element));
|
||||
}
|
||||
|
||||
public BigInteger getElementPropertyAsBigInteger(String elementName) {
|
||||
Element element = _getElementByElementName(elementName);
|
||||
if (element == null) {
|
||||
return (null);
|
||||
}
|
||||
return (URelaxer.getElementPropertyAsBigInteger(element));
|
||||
}
|
||||
|
||||
public Date getElementPropertyAsDate(String elementName) {
|
||||
Element element = _getElementByElementName(elementName);
|
||||
if (element == null) {
|
||||
return (null);
|
||||
}
|
||||
return (URelaxer.getElementPropertyAsDate(element));
|
||||
}
|
||||
|
||||
public Locale getElementPropertyAsLocale(String elementName) {
|
||||
Element element = _getElementByElementName(elementName);
|
||||
if (element == null) {
|
||||
return (null);
|
||||
}
|
||||
return (URelaxer.getElementPropertyAsLocale(element));
|
||||
}
|
||||
|
||||
public URL getElementPropertyAsURL(String elementName) {
|
||||
Element element = _getElementByElementName(elementName);
|
||||
if (element == null) {
|
||||
return (null);
|
||||
}
|
||||
return (URelaxer.getElementPropertyAsURL(element));
|
||||
}
|
||||
|
||||
public java.sql.Timestamp getElementPropertyAsSQLTimestamp(
|
||||
String elementName
|
||||
) {
|
||||
Element element = _getElementByElementName(elementName);
|
||||
if (element == null) {
|
||||
return (null);
|
||||
}
|
||||
return (URelaxer.getElementPropertyAsSQLTimestamp(element));
|
||||
}
|
||||
|
||||
public java.sql.Time getElementPropertyAsSQLTime(
|
||||
String elementName
|
||||
) {
|
||||
Element element = _getElementByElementName(elementName);
|
||||
if (element == null) {
|
||||
return (null);
|
||||
}
|
||||
return (URelaxer.getElementPropertyAsSQLTime(element));
|
||||
}
|
||||
|
||||
public java.sql.Date getElementPropertyAsSQLDate(
|
||||
String elementName
|
||||
) {
|
||||
Element element = _getElementByElementName(elementName);
|
||||
if (element == null) {
|
||||
return (null);
|
||||
}
|
||||
return (URelaxer.getElementPropertyAsSQLDate(element));
|
||||
}
|
||||
|
||||
public byte[] getElementPropertyAsBinaryBASE64(
|
||||
String elementName
|
||||
) {
|
||||
Element element = _getElementByElementName(elementName);
|
||||
if (element == null) {
|
||||
return (null);
|
||||
}
|
||||
return (URelaxer.getElementPropertyAsBinaryBASE64(element));
|
||||
}
|
||||
|
||||
public byte[] getElementPropertyAsBinaryHEX(
|
||||
String elementName
|
||||
) {
|
||||
Element element = _getElementByElementName(elementName);
|
||||
if (element == null) {
|
||||
return (null);
|
||||
}
|
||||
return (URelaxer.getElementPropertyAsBinaryHEX(element));
|
||||
}
|
||||
|
||||
public List getElementPropertyAsStringList(String elementName) {
|
||||
List list = _getElementListByElementName(elementName);
|
||||
int size = list.size();
|
||||
List<String> result = new ArrayList<>();
|
||||
for (int i = 0;i < size;i++) {
|
||||
Element element = (Element)list.get(i);
|
||||
result.add(URelaxer.getElementPropertyAsString(element));
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
public List<Boolean> getElementPropertyAsBooleanList(String elementName) {
|
||||
List<Element> list = _getElementListByElementName(elementName);
|
||||
int size = list.size();
|
||||
List<Boolean> result = new ArrayList<>();
|
||||
for (int i = 0;i < size;i++) {
|
||||
Element element = (Element)list.get(i);
|
||||
result.add(URelaxer.getElementPropertyAsBooleanObject(element));
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
public List<Byte> getElementPropertyAsByteList(String elementName) {
|
||||
List<Element> list = _getElementListByElementName(elementName);
|
||||
int size = list.size();
|
||||
List<Byte> result = new ArrayList<>();
|
||||
for (int i = 0;i < size;i++) {
|
||||
Element element = (Element)list.get(i);
|
||||
result.add(URelaxer.getElementPropertyAsByteObject(element));
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
public List<Short> getElementPropertyAsShortList(String elementName) {
|
||||
List<Element> list = _getElementListByElementName(elementName);
|
||||
int size = list.size();
|
||||
List<Short> result = new ArrayList<>();
|
||||
for (int i = 0;i < size;i++) {
|
||||
Element element = (Element)list.get(i);
|
||||
result.add(URelaxer.getElementPropertyAsShortObject(element));
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
public List<Integer> getElementPropertyAsIntList(String elementName) {
|
||||
List<Element> list = _getElementListByElementName(elementName);
|
||||
int size = list.size();
|
||||
List<Integer> result = new ArrayList<>();
|
||||
for (int i = 0;i < size;i++) {
|
||||
Element element = (Element)list.get(i);
|
||||
result.add(URelaxer.getElementPropertyAsIntObject(element));
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
public List<Long> getElementPropertyAsLongList(String elementName) {
|
||||
List<Element> list = _getElementListByElementName(elementName);
|
||||
int size = list.size();
|
||||
List<Long> result = new ArrayList<>();
|
||||
for (int i = 0;i < size;i++) {
|
||||
Element element = (Element)list.get(i);
|
||||
result.add(URelaxer.getElementPropertyAsLongObject(element));
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
public List<Float> getElementPropertyAsFloatList(String elementName) {
|
||||
List<Element> list = _getElementListByElementName(elementName);
|
||||
int size = list.size();
|
||||
List<Float> result = new ArrayList<>();
|
||||
for (int i = 0;i < size;i++) {
|
||||
Element element = (Element)list.get(i);
|
||||
result.add(URelaxer.getElementPropertyAsFloatObject(element));
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
public List<Double> getElementPropertyAsDoubleList(String elementName) {
|
||||
List<Element> list = _getElementListByElementName(elementName);
|
||||
int size = list.size();
|
||||
List<Double> result = new ArrayList<>();
|
||||
for (int i = 0;i < size;i++) {
|
||||
Element element = (Element)list.get(i);
|
||||
result.add(URelaxer.getElementPropertyAsDoubleObject(element));
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
public List<BigDecimal> getElementPropertyAsBigDecimalList(String elementName) {
|
||||
List<Element> list = _getElementListByElementName(elementName);
|
||||
int size = list.size();
|
||||
List<BigDecimal> result = new ArrayList<>();
|
||||
for (int i = 0;i < size;i++) {
|
||||
Element element = (Element)list.get(i);
|
||||
result.add(URelaxer.getElementPropertyAsBigDecimal(element));
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
public List<BigInteger> getElementPropertyAsBigIntegerList(String elementName) {
|
||||
List<Element> list = _getElementListByElementName(elementName);
|
||||
int size = list.size();
|
||||
List<BigInteger> result = new ArrayList<>();
|
||||
for (int i = 0;i < size;i++) {
|
||||
Element element = (Element)list.get(i);
|
||||
result.add(URelaxer.getElementPropertyAsBigInteger(element));
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
public List<Date> getElementPropertyAsDateList(String elementName) {
|
||||
List<Element> list = _getElementListByElementName(elementName);
|
||||
int size = list.size();
|
||||
List<Date> result = new ArrayList<>();
|
||||
for (int i = 0;i < size;i++) {
|
||||
Element element = (Element)list.get(i);
|
||||
result.add(URelaxer.getElementPropertyAsDate(element));
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
public List<Locale> getElementPropertyAsLocaleList(String elementName) {
|
||||
List<Element> list = _getElementListByElementName(elementName);
|
||||
int size = list.size();
|
||||
List<Locale> result = new ArrayList<>();
|
||||
for (int i = 0;i < size;i++) {
|
||||
Element element = (Element)list.get(i);
|
||||
result.add(URelaxer.getElementPropertyAsLocale(element));
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
public List<URL> getElementPropertyAsURLList(String elementName) {
|
||||
List<Element> list = _getElementListByElementName(elementName);
|
||||
int size = list.size();
|
||||
List<URL> result = new ArrayList<>();
|
||||
for (int i = 0;i < size;i++) {
|
||||
Element element = (Element)list.get(i);
|
||||
result.add(URelaxer.getElementPropertyAsURL(element));
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
public List<Timestamp> getElementPropertyAsSQLTimestampList(
|
||||
String elementName
|
||||
) {
|
||||
List<Element> list = _getElementListByElementName(elementName);
|
||||
int size = list.size();
|
||||
List<Timestamp> result = new ArrayList<>();
|
||||
for (int i = 0;i < size;i++) {
|
||||
Element element = (Element)list.get(i);
|
||||
result.add(URelaxer.getElementPropertyAsSQLTimestamp(element));
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
public List<Time> getElementPropertyAsSQLTimeList(
|
||||
String elementName
|
||||
) {
|
||||
List<Element> list = _getElementListByElementName(elementName);
|
||||
int size = list.size();
|
||||
List<Time> result = new ArrayList<>();
|
||||
for (int i = 0;i < size;i++) {
|
||||
Element element = (Element)list.get(i);
|
||||
result.add(URelaxer.getElementPropertyAsSQLTime(element));
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
public List<Date> getElementPropertyAsSQLDateList(
|
||||
String elementName
|
||||
) {
|
||||
List<Element> list = _getElementListByElementName(elementName);
|
||||
int size = list.size();
|
||||
List<Date> result = new ArrayList<>();
|
||||
for (int i = 0;i < size;i++) {
|
||||
Element element = (Element)list.get(i);
|
||||
result.add(URelaxer.getElementPropertyAsSQLDate(element));
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
public List<byte[]> getElementPropertyAsBinaryBASE64List(
|
||||
String elementName
|
||||
) {
|
||||
List<Element> list = _getElementListByElementName(elementName);
|
||||
int size = list.size();
|
||||
List<byte[]> result = new ArrayList<>();
|
||||
for (int i = 0;i < size;i++) {
|
||||
Element element = (Element)list.get(i);
|
||||
result.add(URelaxer.getElementPropertyAsBinaryBASE64(element));
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
public List<byte[]> getElementPropertyAsBinaryHEXList(
|
||||
String elementName
|
||||
) {
|
||||
List<Element> list = _getElementListByElementName(elementName);
|
||||
int size = list.size();
|
||||
List<byte[]> result = new ArrayList<>();
|
||||
for (int i = 0;i < size;i++) {
|
||||
Element element = (Element)list.get(i);
|
||||
result.add(URelaxer.getElementPropertyAsBinaryHEX(element));
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
private StateClassEntry _getEntryByStateClass(Class stateClass) {
|
||||
if (!isMatch()) {
|
||||
throw (new IllegalStateException());
|
||||
}
|
||||
StateClassEntry entry
|
||||
= (StateClassEntry)entryByStateClass_.get(stateClass);
|
||||
if (entry == null) {
|
||||
throw (new IllegalStateException());
|
||||
}
|
||||
return (entry);
|
||||
}
|
||||
|
||||
private ElementNameEntry _getEntryByElementName(String elementName) {
|
||||
if (!isMatch()) {
|
||||
throw (new IllegalStateException());
|
||||
}
|
||||
ElementNameEntry entry
|
||||
= (ElementNameEntry)entryByElementName_.get(elementName);
|
||||
if (entry == null) {
|
||||
throw (new IllegalStateException());
|
||||
}
|
||||
return (entry);
|
||||
}
|
||||
|
||||
private Element _getElementByElementName(String elementName) {
|
||||
ElementNameEntry entry = _getEntryByElementName(elementName);
|
||||
if (entry.elements.size() == 0) {
|
||||
return (null);
|
||||
} else {
|
||||
return ((Element)entry.elements.get(0));
|
||||
}
|
||||
}
|
||||
|
||||
private List<Element> _getElementListByElementName(String elementName) {
|
||||
ElementNameEntry entry = _getEntryByElementName(elementName);
|
||||
return (entry.elements);
|
||||
}
|
||||
|
||||
public void addElementSlot(String elementName, String occurs) {
|
||||
Entry entry = new ElementNameEntry(elementName, occurs);
|
||||
entries_.add(entry);
|
||||
entryByElementName_.put(elementName, entry);
|
||||
}
|
||||
|
||||
public void addElementSlot(Class stateClass, String occurs) {
|
||||
Entry entry = new StateClassEntry(stateClass, occurs);
|
||||
entries_.add(entry);
|
||||
entryByStateClass_.put(stateClass, entry);
|
||||
}
|
||||
|
||||
public void addHedgeSlot(Class stateClass, String occurs) {
|
||||
Entry entry = new StateClassEntry(stateClass, occurs);
|
||||
entries_.add(entry);
|
||||
entryByStateClass_.put(stateClass, entry);
|
||||
}
|
||||
|
||||
public void addAttributeSlot(Class stateClass, String occurs) {
|
||||
Entry entry = new StateClassEntry(stateClass, occurs);
|
||||
entries_.add(entry);
|
||||
entryByStateClass_.put(stateClass, entry);
|
||||
}
|
||||
|
||||
public boolean isMatch() {
|
||||
if (isMatch_ == null) {
|
||||
isMatch_ = new Boolean(_isMatch());
|
||||
}
|
||||
return (isMatch_.booleanValue());
|
||||
}
|
||||
|
||||
private boolean _isMatch() {
|
||||
Entry[] entries = _getEntries();
|
||||
for (;;) {
|
||||
if (!_isMatchHungry(entries)) {
|
||||
if (_isNoMatch(entries)) {
|
||||
return (false);
|
||||
}
|
||||
return (_isStable(entries));
|
||||
}
|
||||
if (_isUnmatch(entries)) {
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Entry[] _getEntries() {
|
||||
int size = entries_.size();
|
||||
Entry[] entries = new Entry[size];
|
||||
for (int i = 0;i < size;i++) {
|
||||
entries[i] = (Entry)entries_.get(i);
|
||||
}
|
||||
return (entries);
|
||||
}
|
||||
|
||||
private boolean _isNoMatch(Entry[] entries) {
|
||||
for (int i = 0;i < entries.length;i++) {
|
||||
if (entries[i].count > 0) {
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
|
||||
private boolean _isStable(Entry[] entries) {
|
||||
for (int i = 0;i < entries.length;i++) {
|
||||
Entry entry = entries[i];
|
||||
switch (entry.occurs) {
|
||||
case "":
|
||||
if (entry.count != 1) {
|
||||
return (false);
|
||||
} break;
|
||||
case "?":
|
||||
break;
|
||||
case "+":
|
||||
if (entry.count == 0) {
|
||||
return (false);
|
||||
} break;
|
||||
case "*":
|
||||
break;
|
||||
default:
|
||||
throw (new InternalError());
|
||||
}
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
|
||||
private boolean _isUnmatch(Entry[] entries) {
|
||||
for (int i = 0;i < entries.length;i++) {
|
||||
Entry entry = entries[i];
|
||||
switch (entry.occurs) {
|
||||
case "":
|
||||
if (entry.count > 1) {
|
||||
return (true);
|
||||
} break;
|
||||
case "?":
|
||||
if (entry.count > 1) {
|
||||
return (true);
|
||||
} break;
|
||||
case "+":
|
||||
break;
|
||||
case "*":
|
||||
break;
|
||||
default:
|
||||
throw (new InternalError());
|
||||
}
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
private boolean _isMatchHungry(Entry[] entries) {
|
||||
for (int i = 0;i < entries.length;i++) {
|
||||
Entry entry = entries[i];
|
||||
if (entry.isMatchHungry(rstack_)) {
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
static abstract class Entry {
|
||||
public String occurs;
|
||||
public int count = 0;
|
||||
|
||||
protected Entry(String occurs) {
|
||||
this.occurs = occurs;
|
||||
}
|
||||
|
||||
public abstract boolean isMatchHungry(RStack stack);
|
||||
}
|
||||
|
||||
static class StateClassEntry extends Entry {
|
||||
public Class<?> stateClass;
|
||||
public List<RStack> stacks = new ArrayList<>();
|
||||
|
||||
public StateClassEntry(Class<?> stateClass, String occurs) {
|
||||
super(occurs);
|
||||
this.stateClass = stateClass;
|
||||
}
|
||||
|
||||
public boolean isMatchHungry(RStack stack) {
|
||||
//System.out.println("enter:isMatchHungry [" + stateClass + "] - " + stack);
|
||||
try {
|
||||
RStack backup = stack.makeClone();
|
||||
Method method = stateClass.getMethod(
|
||||
"isMatchHungry",
|
||||
new Class[] { RStack.class }
|
||||
);
|
||||
Boolean result = (Boolean)method.invoke(
|
||||
null,
|
||||
new Object[] { stack }
|
||||
);
|
||||
boolean match = result.booleanValue();
|
||||
if (match) {
|
||||
count++;
|
||||
stacks.add(backup);
|
||||
}
|
||||
//System.out.println("leave:isMatchHungry [" + stateClass + "]- " + stack + " = " + match);
|
||||
return (match);
|
||||
} catch ( NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
|
||||
throw (new IllegalArgumentException());
|
||||
}
|
||||
}
|
||||
|
||||
public Object getObject() {
|
||||
if (stacks.size() == 0) {
|
||||
return (null);
|
||||
}
|
||||
RStack stack = (RStack)stacks.get(0);
|
||||
try {
|
||||
Constructor constructor = stateClass.getConstructor(
|
||||
new Class[] { RStack.class }
|
||||
);
|
||||
Object result = constructor.newInstance(
|
||||
new Object[] { stack }
|
||||
);
|
||||
return (result);
|
||||
} catch ( NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
||||
throw (new IllegalArgumentException());
|
||||
}
|
||||
}
|
||||
|
||||
public Object[] getObjects() {
|
||||
int size = stacks.size();
|
||||
Object array = Array.newInstance(stateClass, size);
|
||||
for (int i = 0;i < size;i++) {
|
||||
RStack stack = (RStack)stacks.get(i);
|
||||
try {
|
||||
Constructor constructor = stateClass.getConstructor(
|
||||
new Class[] { RStack.class }
|
||||
);
|
||||
Object result = constructor.newInstance(
|
||||
new Object[] { stack }
|
||||
);
|
||||
Array.set(array, i, result);
|
||||
} catch ( NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
||||
throw (new IllegalArgumentException());
|
||||
}
|
||||
}
|
||||
return ((Object[])array);
|
||||
}
|
||||
}
|
||||
|
||||
static class ElementNameEntry extends Entry {
|
||||
public String elementName;
|
||||
public List<Element> elements = new ArrayList<>();
|
||||
|
||||
public ElementNameEntry(String elementName, String occurs) {
|
||||
super(occurs);
|
||||
this.elementName = elementName;
|
||||
}
|
||||
|
||||
public boolean isMatch(Element element) {
|
||||
String localName = element.getTagName(); // DOM1
|
||||
int index = localName.indexOf(':');
|
||||
if (index != -1) {
|
||||
localName = localName.substring(index + 1);
|
||||
}
|
||||
return (elementName.equals(localName));
|
||||
}
|
||||
|
||||
public boolean isMatchHungry(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
boolean result = isMatch(element);
|
||||
if (result) {
|
||||
stack.popElement();
|
||||
count++;
|
||||
elements.add(element);
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,286 +0,0 @@
|
||||
/*
|
||||
* The Relaxer artifact
|
||||
* Copyright (c) 2000-2004, ASAMI Tomoharu, All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.doubletype.ossa.xml;
|
||||
|
||||
import java.util.*;
|
||||
import org.w3c.dom.*;
|
||||
|
||||
/**
|
||||
* RStack
|
||||
*
|
||||
* @since Mar. 8, 2000
|
||||
* @version May. 22, 2003
|
||||
* @author ASAMI, Tomoharu (asami@relaxer.org)
|
||||
*/
|
||||
public final class RStack {
|
||||
private Element element_;
|
||||
private Object[] children_;
|
||||
// Set<String>
|
||||
// private HashSet consumedAttrs_ = new HashSet();
|
||||
// Set<Attr>
|
||||
private HashSet<Attr> consumedAttrNodes_ = null;
|
||||
// Set<Element>
|
||||
private HashSet<Attr> consumedElementNodes_ = null;
|
||||
// Map<String, String>
|
||||
private HashMap<String,String> pi_ = new HashMap<>();
|
||||
private int index_;
|
||||
// private Element lastPoppedElemnt_ = null;
|
||||
|
||||
protected RStack() {
|
||||
}
|
||||
|
||||
public RStack(Element element) {
|
||||
element_ = element;
|
||||
NodeList nodes = element.getChildNodes();
|
||||
List<Object> list = new ArrayList<>();
|
||||
_makeList(nodes, list);
|
||||
int size = list.size();
|
||||
children_ = new Object[size];
|
||||
children_ = list.toArray(children_);
|
||||
index_ = 0;
|
||||
}
|
||||
|
||||
private void _makeList(NodeList nodes, List<Object> list) {
|
||||
int size = nodes.getLength();
|
||||
StringBuffer buffer = null;
|
||||
for (int i = 0;i < size;i++) {
|
||||
Node node = nodes.item(i);
|
||||
if (node instanceof Element) {
|
||||
if (buffer != null) {
|
||||
list.add(new String(buffer));
|
||||
buffer = null;
|
||||
}
|
||||
list.add(node);
|
||||
} else if (node instanceof Text) {
|
||||
if (buffer == null) {
|
||||
buffer = new StringBuffer();
|
||||
}
|
||||
buffer.append(((Text)node).getData());
|
||||
} else if (node instanceof ProcessingInstruction) {
|
||||
ProcessingInstruction pi = (ProcessingInstruction)node;
|
||||
pi_.put(pi.getTarget(), pi.getData());
|
||||
} else if (node instanceof EntityReference) {
|
||||
_makeList(node.getChildNodes(), list);
|
||||
}
|
||||
}
|
||||
if (buffer != null) {
|
||||
list.add(new String(buffer));
|
||||
}
|
||||
}
|
||||
|
||||
public Element getContextElement() {
|
||||
return (element_);
|
||||
}
|
||||
|
||||
/*
|
||||
public Element getLastPoppedElement() {
|
||||
return (lastPoppedElemnt_);
|
||||
}
|
||||
*/
|
||||
|
||||
public boolean isEmpty() {
|
||||
return (index_ == children_.length);
|
||||
}
|
||||
|
||||
public boolean isEmptyElement() {
|
||||
if (index_ == children_.length) {
|
||||
return (true);
|
||||
}
|
||||
for (int i = index_;i < children_.length;i++) {
|
||||
if (children_[i] instanceof Element) {
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
|
||||
public Object pop() {
|
||||
return (children_[index_++]);
|
||||
}
|
||||
|
||||
public Object peek() {
|
||||
if (index_ == children_.length) {
|
||||
return (null);
|
||||
}
|
||||
return (children_[index_]);
|
||||
}
|
||||
|
||||
public Element popElement() {
|
||||
if (index_ == children_.length) {
|
||||
return (null);
|
||||
}
|
||||
while (index_ < children_.length) {
|
||||
Object node = children_[index_++];
|
||||
if (node instanceof Element) {
|
||||
// lastPoppedElemnt_ = (Element)node;
|
||||
// return (lastPoppedElemnt_);
|
||||
return ((Element)node);
|
||||
}
|
||||
}
|
||||
return (null);
|
||||
}
|
||||
|
||||
public Element peekElement() {
|
||||
if (index_ == children_.length) {
|
||||
return (null);
|
||||
}
|
||||
for (int i = index_;i < children_.length;i++) {
|
||||
Object node = children_[i];
|
||||
if (node instanceof Element) {
|
||||
return ((Element)node);
|
||||
}
|
||||
}
|
||||
return (null);
|
||||
}
|
||||
|
||||
public Element[] peekElements() {
|
||||
if (index_ == children_.length) {
|
||||
return (null);
|
||||
}
|
||||
List<Element> list = new ArrayList<>();
|
||||
for (int i = index_;i < children_.length;i++) {
|
||||
Object node = children_[i];
|
||||
if (node instanceof Element) {
|
||||
list.add((Element)node);
|
||||
}
|
||||
}
|
||||
Element[] elements = new Element[list.size()];
|
||||
return ((Element[])list.toArray(elements));
|
||||
}
|
||||
|
||||
/*
|
||||
public boolean hasAttributeHungry(String name) {
|
||||
if (isConsumedAttribute(name)) {
|
||||
return (false);
|
||||
}
|
||||
setCosumedAttribute(name);
|
||||
return (URelaxer.hasAttribute(element_, name));
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
public boolean isConsumedAttribute(String name) {
|
||||
return (consumedAttrs_.contains(name));
|
||||
}
|
||||
|
||||
public boolean isConsumedAttribute(String uri, String name) {
|
||||
return (consumedAttrs_.contains(uri + "$" + name));
|
||||
}
|
||||
|
||||
public void setConsumedAttribute(String name) {
|
||||
if (isConsumedAttribute(name)) {
|
||||
throw (new InternalError());
|
||||
}
|
||||
consumedAttrs_.add(name);
|
||||
}
|
||||
|
||||
public void setConsumedAttribute(String uri, String name) {
|
||||
String fullname = uri + "$" + name;
|
||||
if (isConsumedAttribute(fullname)) {
|
||||
throw (new InternalError());
|
||||
}
|
||||
consumedAttrs_.add(fullname);
|
||||
}
|
||||
*/
|
||||
|
||||
public Map getPIMap() {
|
||||
return ((Map)pi_.clone());
|
||||
}
|
||||
|
||||
public boolean isConsumedElement(Attr attr) {
|
||||
if (consumedElementNodes_ == null) {
|
||||
return (false);
|
||||
}
|
||||
return (consumedElementNodes_.contains(attr));
|
||||
}
|
||||
|
||||
public void consumeElement(Attr attr) {
|
||||
if (consumedElementNodes_ == null) {
|
||||
consumedElementNodes_ = new HashSet<>();
|
||||
}
|
||||
consumedElementNodes_.add(attr);
|
||||
}
|
||||
|
||||
public boolean isConsumedAttribute(Attr attr) {
|
||||
if (consumedAttrNodes_ == null) {
|
||||
return (false);
|
||||
}
|
||||
return (consumedAttrNodes_.contains(attr));
|
||||
}
|
||||
|
||||
public void consumeAttribute(Attr attr) {
|
||||
if (attr == null) {
|
||||
return;
|
||||
}
|
||||
if (consumedAttrNodes_ == null) {
|
||||
consumedAttrNodes_ = new HashSet<>();
|
||||
}
|
||||
consumedAttrNodes_.add(attr);
|
||||
}
|
||||
|
||||
public void addDirectAttributes(Map<String,String> map) {
|
||||
NamedNodeMap attrs = element_.getAttributes();
|
||||
int size = attrs.getLength();
|
||||
for (int i = 0;i < size;i++) {
|
||||
Attr attr = (Attr)attrs.item(i);
|
||||
if (!isConsumedAttribute(attr)) {
|
||||
map.put(attr.getName(), attr.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public RStack makeClone() {
|
||||
RStack newStack = new RStack();
|
||||
newStack.element_ = element_;
|
||||
newStack.children_ = (Object[])children_.clone();
|
||||
if (consumedAttrNodes_ != null) {
|
||||
newStack.consumedAttrNodes_
|
||||
= (HashSet<Attr>)consumedAttrNodes_.clone();
|
||||
}
|
||||
if (consumedElementNodes_ != null) {
|
||||
newStack.consumedElementNodes_
|
||||
= (HashSet<Attr>)consumedElementNodes_.clone();
|
||||
}
|
||||
newStack.pi_ = (HashMap<String,String>)pi_.clone();
|
||||
newStack.index_ = index_;
|
||||
return (newStack);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("[");
|
||||
if (index_ < children_.length) {
|
||||
Object object = children_[index_];
|
||||
buffer.append(object);
|
||||
for (int i = index_ + 1;i < children_.length;i++) {
|
||||
buffer.append(",");
|
||||
object = children_[i];
|
||||
buffer.append(object);
|
||||
}
|
||||
}
|
||||
buffer.append("]");
|
||||
return (new String(buffer));
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
Copyright(c) 2000-2004 ASAMI,Tomoharu. All rights reserved.
|
||||
Relaxer Version 1.1b (20040122) by asami@relaxer.org
|
||||
@@ -1,2 +0,0 @@
|
||||
Copyright(c) 2000-2004 ASAMI,Tomoharu. All rights reserved.
|
||||
Relaxer Version 1.1b (20040510) by asami@relaxer.org
|
||||
@@ -1,8 +0,0 @@
|
||||
#Relaxer properties
|
||||
#Sat May 01 17:44:29 EDT 2004
|
||||
java.pattern.composite=true
|
||||
java.pattern.factory=true
|
||||
java.jaxp=true
|
||||
java.package=org.doubletype.ossa.xml
|
||||
relaxer.eclipse=true
|
||||
java.name.class.prefix=X
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,759 +0,0 @@
|
||||
/*
|
||||
* The Relaxer artifact
|
||||
* Copyright (c) 2000-2004, ASAMI Tomoharu, All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.doubletype.ossa.xml;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.xml.parsers.*;
|
||||
import org.w3c.dom.*;
|
||||
import org.xml.sax.*;
|
||||
|
||||
/**
|
||||
* <b>XContour</b> is generated from glyph.rng by Relaxer.
|
||||
* This class is derived from:
|
||||
*
|
||||
* <!-- for programmer
|
||||
* <element name="contour" ns="http://doubletype.org/ns/glyph/0.0">
|
||||
* <optional>
|
||||
* <attribute name="type"/>
|
||||
* </optional>
|
||||
* <oneOrMore>
|
||||
* <ref name="contourPoint"/>
|
||||
* </oneOrMore>
|
||||
* </element>-->
|
||||
* <!-- for javadoc -->
|
||||
* <pre> <element name="contour" ns="http://doubletype.org/ns/glyph/0.0">
|
||||
* <optional>
|
||||
* <attribute name="type"/>
|
||||
* </optional>
|
||||
* <oneOrMore>
|
||||
* <ref name="contourPoint"/>
|
||||
* </oneOrMore>
|
||||
* </element></pre>
|
||||
*
|
||||
* @version glyph.rng (Tue Nov 09 20:22:48 EST 2004)
|
||||
* @author Relaxer 1.1b (http://www.relaxer.org)
|
||||
*/
|
||||
public class XContour implements java.io.Serializable, Cloneable, IRNode {
|
||||
private String type_;
|
||||
// List<XContourPoint>
|
||||
private List<XContourPoint> contourPoint_ = new ArrayList<>();
|
||||
private IRNode parentRNode_;
|
||||
|
||||
/**
|
||||
* Creates a <code>XContour</code>.
|
||||
*
|
||||
*/
|
||||
public XContour() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XContour</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public XContour(XContour source) {
|
||||
setup(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XContour</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public XContour(RStack stack) {
|
||||
setup(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XContour</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public XContour(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XContour</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public XContour(Element element) {
|
||||
setup(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XContour</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XContour(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XContour</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XContour(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XContour</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XContour(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XContour</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XContour(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XContour</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XContour(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(is);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XContour</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XContour(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XContour</code> by the XContour <code>source</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public void setup(XContour source) {
|
||||
int size;
|
||||
type_ = source.type_;
|
||||
this.contourPoint_.clear();
|
||||
size = source.contourPoint_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
addContourPoint((XContourPoint)source.getContourPoint(i).clone());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XContour</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public void setup(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XContour</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public void setup(Element element) {
|
||||
init(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XContour</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public void setup(RStack stack) {
|
||||
init(stack.popElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param element
|
||||
*/
|
||||
private void init(Element element) {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
RStack stack = new RStack(element);
|
||||
type_ = URelaxer.getAttributePropertyAsString(element, "type");
|
||||
contourPoint_.clear();
|
||||
while (true) {
|
||||
if (XContourPoint.isMatch(stack)) {
|
||||
addContourPoint(factory.createXContourPoint(stack));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Object
|
||||
*/
|
||||
public Object clone() {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
return (factory.createXContour((XContour)this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM representation of the object.
|
||||
* Result is appended to the Node <code>parent</code>.
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
public void makeElement(Node parent) {
|
||||
Document doc;
|
||||
if (parent instanceof Document) {
|
||||
doc = (Document)parent;
|
||||
} else {
|
||||
doc = parent.getOwnerDocument();
|
||||
}
|
||||
Element element = doc.createElement("contour");
|
||||
int size;
|
||||
if (this.type_ != null) {
|
||||
URelaxer.setAttributePropertyByString(element, "type", this.type_);
|
||||
}
|
||||
size = this.contourPoint_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XContourPoint value = (XContourPoint)this.contourPoint_.get(i);
|
||||
value.makeElement(element);
|
||||
}
|
||||
parent.appendChild(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XContour</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file.toURI().toURL());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XContour</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(uri, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XContour</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XContour</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XContour</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XContour</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM document representation of the object.
|
||||
*
|
||||
* @exception ParserConfigurationException
|
||||
* @return Document
|
||||
*/
|
||||
public Document makeDocument() throws ParserConfigurationException {
|
||||
Document doc = UJAXP.makeDocument();
|
||||
makeElement(doc);
|
||||
return (doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the String property <b>type</b>.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getType() {
|
||||
return (type_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the String property <b>type</b>.
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
public void setType(String type) {
|
||||
this.type_ = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the XContourPoint property <b>contourPoint</b>.
|
||||
*
|
||||
* @return XContourPoint[]
|
||||
*/
|
||||
public XContourPoint[] getContourPoint() {
|
||||
XContourPoint[] array = new XContourPoint[contourPoint_.size()];
|
||||
return ((XContourPoint[])contourPoint_.toArray(array));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XContourPoint property <b>contourPoint</b>.
|
||||
*
|
||||
* @param contourPoint
|
||||
*/
|
||||
public void setContourPoint(XContourPoint[] contourPoint) {
|
||||
this.contourPoint_.clear();
|
||||
for (int i = 0;i < contourPoint.length;i++) {
|
||||
addContourPoint(contourPoint[i]);
|
||||
}
|
||||
for (int i = 0;i < contourPoint.length;i++) {
|
||||
contourPoint[i].rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XContourPoint property <b>contourPoint</b>.
|
||||
*
|
||||
* @param contourPoint
|
||||
*/
|
||||
public void setContourPoint(XContourPoint contourPoint) {
|
||||
this.contourPoint_.clear();
|
||||
addContourPoint(contourPoint);
|
||||
if (contourPoint != null) {
|
||||
contourPoint.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the XContourPoint property <b>contourPoint</b>.
|
||||
*
|
||||
* @param contourPoint
|
||||
*/
|
||||
public void addContourPoint(XContourPoint contourPoint) {
|
||||
this.contourPoint_.add(contourPoint);
|
||||
if (contourPoint != null) {
|
||||
contourPoint.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the XContourPoint property <b>contourPoint</b>.
|
||||
*
|
||||
* @param contourPoint
|
||||
*/
|
||||
public void addContourPoint(XContourPoint[] contourPoint) {
|
||||
for (int i = 0;i < contourPoint.length;i++) {
|
||||
addContourPoint(contourPoint[i]);
|
||||
}
|
||||
for (int i = 0;i < contourPoint.length;i++) {
|
||||
contourPoint[i].rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets number of the XContourPoint property <b>contourPoint</b>.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public int sizeContourPoint() {
|
||||
return (contourPoint_.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the XContourPoint property <b>contourPoint</b> by index.
|
||||
*
|
||||
* @param index
|
||||
* @return XContourPoint
|
||||
*/
|
||||
public XContourPoint getContourPoint(int index) {
|
||||
return ((XContourPoint)contourPoint_.get(index));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XContourPoint property <b>contourPoint</b> by index.
|
||||
*
|
||||
* @param index
|
||||
* @param contourPoint
|
||||
*/
|
||||
public void setContourPoint(int index, XContourPoint contourPoint) {
|
||||
this.contourPoint_.set(index, contourPoint);
|
||||
if (contourPoint != null) {
|
||||
contourPoint.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the XContourPoint property <b>contourPoint</b> by index.
|
||||
*
|
||||
* @param index
|
||||
* @param contourPoint
|
||||
*/
|
||||
public void addContourPoint(int index, XContourPoint contourPoint) {
|
||||
this.contourPoint_.add(index, contourPoint);
|
||||
if (contourPoint != null) {
|
||||
contourPoint.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the XContourPoint property <b>contourPoint</b> by index.
|
||||
*
|
||||
* @param index
|
||||
*/
|
||||
public void removeContourPoint(int index) {
|
||||
this.contourPoint_.remove(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the XContourPoint property <b>contourPoint</b> by object.
|
||||
*
|
||||
* @param contourPoint
|
||||
*/
|
||||
public void removeContourPoint(XContourPoint contourPoint) {
|
||||
this.contourPoint_.remove(contourPoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the XContourPoint property <b>contourPoint</b>.
|
||||
*
|
||||
*/
|
||||
public void clearContourPoint() {
|
||||
this.contourPoint_.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String makeTextDocument() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
makeTextElement(buffer);
|
||||
return (new String(buffer));
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(StringBuffer buffer) {
|
||||
int size;
|
||||
buffer.append("<contour");
|
||||
if (type_ != null) {
|
||||
buffer.append(" type=\"");
|
||||
buffer.append(URelaxer.escapeAttrQuot(URelaxer.getString(getType())));
|
||||
buffer.append("\"");
|
||||
}
|
||||
buffer.append(">");
|
||||
size = this.contourPoint_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XContourPoint value = (XContourPoint)this.contourPoint_.get(i);
|
||||
value.makeTextElement(buffer);
|
||||
}
|
||||
buffer.append("</contour>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextElement(Writer buffer) throws IOException {
|
||||
int size;
|
||||
buffer.write("<contour");
|
||||
if (type_ != null) {
|
||||
buffer.write(" type=\"");
|
||||
buffer.write(URelaxer.escapeAttrQuot(URelaxer.getString(getType())));
|
||||
buffer.write("\"");
|
||||
}
|
||||
buffer.write(">");
|
||||
size = this.contourPoint_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XContourPoint value = (XContourPoint)this.contourPoint_.get(i);
|
||||
value.makeTextElement(buffer);
|
||||
}
|
||||
buffer.write("</contour>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(PrintWriter buffer) {
|
||||
int size;
|
||||
buffer.print("<contour");
|
||||
if (type_ != null) {
|
||||
buffer.print(" type=\"");
|
||||
buffer.print(URelaxer.escapeAttrQuot(URelaxer.getString(getType())));
|
||||
buffer.print("\"");
|
||||
}
|
||||
buffer.print(">");
|
||||
size = this.contourPoint_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XContourPoint value = (XContourPoint)this.contourPoint_.get(i);
|
||||
value.makeTextElement(buffer);
|
||||
}
|
||||
buffer.print("</contour>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(StringBuffer buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextAttribute(Writer buffer) throws IOException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(PrintWriter buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the property value as String.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getTypeAsString() {
|
||||
return (URelaxer.getString(getType()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the property value by String.
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public void setTypeByString(String string) {
|
||||
setType(string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String representation of this object.
|
||||
* While this method informs as XML format representaion,
|
||||
* it's purpose is just information, not making
|
||||
* a rigid XML documentation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String toString() {
|
||||
try {
|
||||
return (makeTextDocument());
|
||||
} catch (Exception e) {
|
||||
return (super.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @return IRNode
|
||||
*/
|
||||
public IRNode rGetParentRNode() {
|
||||
return (parentRNode_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @param parentRNode
|
||||
*/
|
||||
public void rSetParentRNode(IRNode parentRNode) {
|
||||
this.parentRNode_ = parentRNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets child RNodes.
|
||||
*
|
||||
* @return IRNode[]
|
||||
*/
|
||||
public IRNode[] rGetRNodes() {
|
||||
List<IRNode> classNodes = new ArrayList<>();
|
||||
classNodes.addAll(contourPoint_);
|
||||
IRNode[] nodes = new IRNode[classNodes.size()];
|
||||
return ((IRNode[])classNodes.toArray(nodes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if a Element <code>element</code> is valid
|
||||
* for the <code>XContour</code>.
|
||||
*
|
||||
* @param element
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(Element element) {
|
||||
if (!URelaxer.isTargetElement(element, "contour")) {
|
||||
return (false);
|
||||
}
|
||||
RStack target = new RStack(element);
|
||||
boolean $match$ = false;
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
Element child;
|
||||
if (!XContourPoint.isMatchHungry(target)) {
|
||||
return (false);
|
||||
}
|
||||
$match$ = true;
|
||||
while (true) {
|
||||
if (!XContourPoint.isMatchHungry(target)) {
|
||||
break;
|
||||
}
|
||||
$match$ = true;
|
||||
}
|
||||
if (!target.isEmptyElement()) {
|
||||
return (false);
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XContour</code>.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
return (isMatch(element));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XContour</code>.
|
||||
* This method consumes the stack contents during matching operation.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatchHungry(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
if (isMatch(element)) {
|
||||
stack.popElement();
|
||||
return (true);
|
||||
} else {
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,666 +0,0 @@
|
||||
/*
|
||||
* The Relaxer artifact
|
||||
* Copyright (c) 2000-2004, ASAMI Tomoharu, All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.doubletype.ossa.xml;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.xml.parsers.*;
|
||||
import org.w3c.dom.*;
|
||||
import org.xml.sax.*;
|
||||
|
||||
/**
|
||||
* <b>XControlPoint</b> is generated from glyph.rng by Relaxer.
|
||||
* This class is derived from:
|
||||
*
|
||||
* <!-- for programmer
|
||||
* <element name="controlPoint" ns="http://doubletype.org/ns/glyph/0.0">
|
||||
* <attribute name="first">
|
||||
* <data type="boolean"/>
|
||||
* </attribute>
|
||||
* <attribute name="smooth">
|
||||
* <data type="boolean"/>
|
||||
* </attribute>
|
||||
* <ref name="contourPoint"/>
|
||||
* </element>-->
|
||||
* <!-- for javadoc -->
|
||||
* <pre> <element name="controlPoint" ns="http://doubletype.org/ns/glyph/0.0">
|
||||
* <attribute name="first">
|
||||
* <data type="boolean"/>
|
||||
* </attribute>
|
||||
* <attribute name="smooth">
|
||||
* <data type="boolean"/>
|
||||
* </attribute>
|
||||
* <ref name="contourPoint"/>
|
||||
* </element></pre>
|
||||
*
|
||||
* @version glyph.rng (Tue Nov 09 20:22:48 EST 2004)
|
||||
* @author Relaxer 1.1b (http://www.relaxer.org)
|
||||
*/
|
||||
public class XControlPoint implements java.io.Serializable, Cloneable, IRNode {
|
||||
private boolean first_;
|
||||
private boolean smooth_;
|
||||
private XContourPoint contourPoint_;
|
||||
private IRNode parentRNode_;
|
||||
|
||||
/**
|
||||
* Creates a <code>XControlPoint</code>.
|
||||
*
|
||||
*/
|
||||
public XControlPoint() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XControlPoint</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public XControlPoint(XControlPoint source) {
|
||||
setup(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XControlPoint</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public XControlPoint(RStack stack) {
|
||||
setup(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XControlPoint</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public XControlPoint(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XControlPoint</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public XControlPoint(Element element) {
|
||||
setup(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XControlPoint</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XControlPoint(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XControlPoint</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XControlPoint(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XControlPoint</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XControlPoint(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XControlPoint</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XControlPoint(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XControlPoint</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XControlPoint(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(is);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XControlPoint</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XControlPoint(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XControlPoint</code> by the XControlPoint <code>source</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public void setup(XControlPoint source) {
|
||||
int size;
|
||||
first_ = source.first_;
|
||||
smooth_ = source.smooth_;
|
||||
if (source.contourPoint_ != null) {
|
||||
setContourPoint((XContourPoint)source.getContourPoint().clone());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XControlPoint</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public void setup(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XControlPoint</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public void setup(Element element) {
|
||||
init(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XControlPoint</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public void setup(RStack stack) {
|
||||
init(stack.popElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param element
|
||||
*/
|
||||
private void init(Element element) {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
RStack stack = new RStack(element);
|
||||
first_ = URelaxer.getAttributePropertyAsBoolean(element, "first");
|
||||
smooth_ = URelaxer.getAttributePropertyAsBoolean(element, "smooth");
|
||||
setContourPoint(factory.createXContourPoint(stack));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Object
|
||||
*/
|
||||
public Object clone() {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
return (factory.createXControlPoint((XControlPoint)this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM representation of the object.
|
||||
* Result is appended to the Node <code>parent</code>.
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
public void makeElement(Node parent) {
|
||||
Document doc;
|
||||
if (parent instanceof Document) {
|
||||
doc = (Document)parent;
|
||||
} else {
|
||||
doc = parent.getOwnerDocument();
|
||||
}
|
||||
Element element = doc.createElement("controlPoint");
|
||||
int size;
|
||||
URelaxer.setAttributePropertyByBoolean(element, "first", this.first_);
|
||||
URelaxer.setAttributePropertyByBoolean(element, "smooth", this.smooth_);
|
||||
this.contourPoint_.makeElement(element);
|
||||
parent.appendChild(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XControlPoint</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file.toURI().toURL());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XControlPoint</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(uri, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XControlPoint</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XControlPoint</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XControlPoint</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XControlPoint</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM document representation of the object.
|
||||
*
|
||||
* @exception ParserConfigurationException
|
||||
* @return Document
|
||||
*/
|
||||
public Document makeDocument() throws ParserConfigurationException {
|
||||
Document doc = UJAXP.makeDocument();
|
||||
makeElement(doc);
|
||||
return (doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the boolean property <b>first</b>.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean getFirst() {
|
||||
return (first_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the boolean property <b>first</b>.
|
||||
*
|
||||
* @param first
|
||||
*/
|
||||
public void setFirst(boolean first) {
|
||||
this.first_ = first;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the boolean property <b>smooth</b>.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean getSmooth() {
|
||||
return (smooth_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the boolean property <b>smooth</b>.
|
||||
*
|
||||
* @param smooth
|
||||
*/
|
||||
public void setSmooth(boolean smooth) {
|
||||
this.smooth_ = smooth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the XContourPoint property <b>contourPoint</b>.
|
||||
*
|
||||
* @return XContourPoint
|
||||
*/
|
||||
public XContourPoint getContourPoint() {
|
||||
return (contourPoint_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XContourPoint property <b>contourPoint</b>.
|
||||
*
|
||||
* @param contourPoint
|
||||
*/
|
||||
public void setContourPoint(XContourPoint contourPoint) {
|
||||
this.contourPoint_ = contourPoint;
|
||||
if (contourPoint != null) {
|
||||
contourPoint.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String makeTextDocument() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
makeTextElement(buffer);
|
||||
return (new String(buffer));
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(StringBuffer buffer) {
|
||||
int size;
|
||||
buffer.append("<controlPoint");
|
||||
buffer.append(" first=\"");
|
||||
buffer.append(URelaxer.getString(getFirst()));
|
||||
buffer.append("\"");
|
||||
buffer.append(" smooth=\"");
|
||||
buffer.append(URelaxer.getString(getSmooth()));
|
||||
buffer.append("\"");
|
||||
buffer.append(">");
|
||||
contourPoint_.makeTextElement(buffer);
|
||||
buffer.append("</controlPoint>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextElement(Writer buffer) throws IOException {
|
||||
int size;
|
||||
buffer.write("<controlPoint");
|
||||
buffer.write(" first=\"");
|
||||
buffer.write(URelaxer.getString(getFirst()));
|
||||
buffer.write("\"");
|
||||
buffer.write(" smooth=\"");
|
||||
buffer.write(URelaxer.getString(getSmooth()));
|
||||
buffer.write("\"");
|
||||
buffer.write(">");
|
||||
contourPoint_.makeTextElement(buffer);
|
||||
buffer.write("</controlPoint>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(PrintWriter buffer) {
|
||||
int size;
|
||||
buffer.print("<controlPoint");
|
||||
buffer.print(" first=\"");
|
||||
buffer.print(URelaxer.getString(getFirst()));
|
||||
buffer.print("\"");
|
||||
buffer.print(" smooth=\"");
|
||||
buffer.print(URelaxer.getString(getSmooth()));
|
||||
buffer.print("\"");
|
||||
buffer.print(">");
|
||||
contourPoint_.makeTextElement(buffer);
|
||||
buffer.print("</controlPoint>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(StringBuffer buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextAttribute(Writer buffer) throws IOException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(PrintWriter buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the property value as String.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getFirstAsString() {
|
||||
return (URelaxer.getString(getFirst()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the property value as String.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getSmoothAsString() {
|
||||
return (URelaxer.getString(getSmooth()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the property value by String.
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public void setFirstByString(String string) {
|
||||
setFirst(new Boolean(string).booleanValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the property value by String.
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public void setSmoothByString(String string) {
|
||||
setSmooth(new Boolean(string).booleanValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String representation of this object.
|
||||
* While this method informs as XML format representaion,
|
||||
* it's purpose is just information, not making
|
||||
* a rigid XML documentation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String toString() {
|
||||
try {
|
||||
return (makeTextDocument());
|
||||
} catch (Exception e) {
|
||||
return (super.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @return IRNode
|
||||
*/
|
||||
public IRNode rGetParentRNode() {
|
||||
return (parentRNode_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @param parentRNode
|
||||
*/
|
||||
public void rSetParentRNode(IRNode parentRNode) {
|
||||
this.parentRNode_ = parentRNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets child RNodes.
|
||||
*
|
||||
* @return IRNode[]
|
||||
*/
|
||||
public IRNode[] rGetRNodes() {
|
||||
List<IRNode> classNodes = new ArrayList<>();
|
||||
if (contourPoint_ != null) {
|
||||
classNodes.add(contourPoint_);
|
||||
}
|
||||
IRNode[] nodes = new IRNode[classNodes.size()];
|
||||
return ((IRNode[])classNodes.toArray(nodes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if a Element <code>element</code> is valid
|
||||
* for the <code>XControlPoint</code>.
|
||||
*
|
||||
* @param element
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(Element element) {
|
||||
if (!URelaxer.isTargetElement(element, "controlPoint")) {
|
||||
return (false);
|
||||
}
|
||||
RStack target = new RStack(element);
|
||||
boolean $match$ = false;
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
Element child;
|
||||
if (!URelaxer.hasAttributeHungry(target, "first")) {
|
||||
return (false);
|
||||
}
|
||||
$match$ = true;
|
||||
if (!URelaxer.hasAttributeHungry(target, "smooth")) {
|
||||
return (false);
|
||||
}
|
||||
$match$ = true;
|
||||
if (!XContourPoint.isMatchHungry(target)) {
|
||||
return (false);
|
||||
}
|
||||
$match$ = true;
|
||||
if (!target.isEmptyElement()) {
|
||||
return (false);
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XControlPoint</code>.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
return (isMatch(element));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XControlPoint</code>.
|
||||
* This method consumes the stack contents during matching operation.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatchHungry(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
if (isMatch(element)) {
|
||||
stack.popElement();
|
||||
return (true);
|
||||
} else {
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,632 +0,0 @@
|
||||
/*
|
||||
* The Relaxer artifact
|
||||
* Copyright (c) 2000-2004, ASAMI Tomoharu, All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.doubletype.ossa.xml;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.xml.parsers.*;
|
||||
import org.w3c.dom.*;
|
||||
import org.xml.sax.*;
|
||||
|
||||
/**
|
||||
* <b>XGlyphFile</b> is generated from glyph.rng by Relaxer.
|
||||
* This class is derived from:
|
||||
*
|
||||
* <!-- for programmer
|
||||
* <element name="glyphFile" ns="http://doubletype.org/ns/glyph/0.0">
|
||||
* <attribute name="href"/>
|
||||
* <attribute name="unicode">
|
||||
* <data type="long"/>
|
||||
* </attribute>
|
||||
* </element>-->
|
||||
* <!-- for javadoc -->
|
||||
* <pre> <element name="glyphFile" ns="http://doubletype.org/ns/glyph/0.0">
|
||||
* <attribute name="href"/>
|
||||
* <attribute name="unicode">
|
||||
* <data type="long"/>
|
||||
* </attribute>
|
||||
* </element></pre>
|
||||
*
|
||||
* @version glyph.rng (Tue Nov 09 20:22:48 EST 2004)
|
||||
* @author Relaxer 1.1b (http://www.relaxer.org)
|
||||
*/
|
||||
public class XGlyphFile implements java.io.Serializable, Cloneable, IRNode {
|
||||
private String href_;
|
||||
private long unicode_;
|
||||
private IRNode parentRNode_;
|
||||
|
||||
/**
|
||||
* Creates a <code>XGlyphFile</code>.
|
||||
*
|
||||
*/
|
||||
public XGlyphFile() {
|
||||
href_ = "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XGlyphFile</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public XGlyphFile(XGlyphFile source) {
|
||||
setup(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XGlyphFile</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public XGlyphFile(RStack stack) {
|
||||
setup(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XGlyphFile</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public XGlyphFile(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XGlyphFile</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public XGlyphFile(Element element) {
|
||||
setup(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XGlyphFile</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XGlyphFile(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XGlyphFile</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XGlyphFile(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XGlyphFile</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XGlyphFile(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XGlyphFile</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XGlyphFile(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XGlyphFile</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XGlyphFile(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(is);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XGlyphFile</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XGlyphFile(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XGlyphFile</code> by the XGlyphFile <code>source</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public void setup(XGlyphFile source) {
|
||||
int size;
|
||||
href_ = source.href_;
|
||||
unicode_ = source.unicode_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XGlyphFile</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public void setup(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XGlyphFile</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public void setup(Element element) {
|
||||
init(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XGlyphFile</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public void setup(RStack stack) {
|
||||
init(stack.popElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param element
|
||||
*/
|
||||
private void init(Element element) {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
RStack stack = new RStack(element);
|
||||
href_ = URelaxer.getAttributePropertyAsString(element, "href");
|
||||
unicode_ = URelaxer.getAttributePropertyAsLong(element, "unicode");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Object
|
||||
*/
|
||||
public Object clone() {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
return (factory.createXGlyphFile((XGlyphFile)this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM representation of the object.
|
||||
* Result is appended to the Node <code>parent</code>.
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
public void makeElement(Node parent) {
|
||||
Document doc;
|
||||
if (parent instanceof Document) {
|
||||
doc = (Document)parent;
|
||||
} else {
|
||||
doc = parent.getOwnerDocument();
|
||||
}
|
||||
Element element = doc.createElement("glyphFile");
|
||||
int size;
|
||||
if (this.href_ != null) {
|
||||
URelaxer.setAttributePropertyByString(element, "href", this.href_);
|
||||
}
|
||||
URelaxer.setAttributePropertyByLong(element, "unicode", this.unicode_);
|
||||
parent.appendChild(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XGlyphFile</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file.toURI().toURL());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XGlyphFile</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(uri, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XGlyphFile</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XGlyphFile</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XGlyphFile</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XGlyphFile</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM document representation of the object.
|
||||
*
|
||||
* @exception ParserConfigurationException
|
||||
* @return Document
|
||||
*/
|
||||
public Document makeDocument() throws ParserConfigurationException {
|
||||
Document doc = UJAXP.makeDocument();
|
||||
makeElement(doc);
|
||||
return (doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the String property <b>href</b>.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getHref() {
|
||||
return (href_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the String property <b>href</b>.
|
||||
*
|
||||
* @param href
|
||||
*/
|
||||
public void setHref(String href) {
|
||||
this.href_ = href;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the long property <b>unicode</b>.
|
||||
*
|
||||
* @return long
|
||||
*/
|
||||
public long getUnicode() {
|
||||
return (unicode_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the long property <b>unicode</b>.
|
||||
*
|
||||
* @param unicode
|
||||
*/
|
||||
public void setUnicode(long unicode) {
|
||||
this.unicode_ = unicode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String makeTextDocument() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
makeTextElement(buffer);
|
||||
return (new String(buffer));
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(StringBuffer buffer) {
|
||||
int size;
|
||||
buffer.append("<glyphFile");
|
||||
if (href_ != null) {
|
||||
buffer.append(" href=\"");
|
||||
buffer.append(URelaxer.escapeAttrQuot(URelaxer.getString(getHref())));
|
||||
buffer.append("\"");
|
||||
}
|
||||
buffer.append(" unicode=\"");
|
||||
buffer.append(URelaxer.getString(getUnicode()));
|
||||
buffer.append("\"");
|
||||
buffer.append(">");
|
||||
buffer.append("</glyphFile>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextElement(Writer buffer) throws IOException {
|
||||
int size;
|
||||
buffer.write("<glyphFile");
|
||||
if (href_ != null) {
|
||||
buffer.write(" href=\"");
|
||||
buffer.write(URelaxer.escapeAttrQuot(URelaxer.getString(getHref())));
|
||||
buffer.write("\"");
|
||||
}
|
||||
buffer.write(" unicode=\"");
|
||||
buffer.write(URelaxer.getString(getUnicode()));
|
||||
buffer.write("\"");
|
||||
buffer.write(">");
|
||||
buffer.write("</glyphFile>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(PrintWriter buffer) {
|
||||
int size;
|
||||
buffer.print("<glyphFile");
|
||||
if (href_ != null) {
|
||||
buffer.print(" href=\"");
|
||||
buffer.print(URelaxer.escapeAttrQuot(URelaxer.getString(getHref())));
|
||||
buffer.print("\"");
|
||||
}
|
||||
buffer.print(" unicode=\"");
|
||||
buffer.print(URelaxer.getString(getUnicode()));
|
||||
buffer.print("\"");
|
||||
buffer.print(">");
|
||||
buffer.print("</glyphFile>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(StringBuffer buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextAttribute(Writer buffer) throws IOException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(PrintWriter buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the property value as String.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getHrefAsString() {
|
||||
return (URelaxer.getString(getHref()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the property value as String.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getUnicodeAsString() {
|
||||
return (URelaxer.getString(getUnicode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the property value by String.
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public void setHrefByString(String string) {
|
||||
setHref(string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the property value by String.
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public void setUnicodeByString(String string) {
|
||||
setUnicode(Long.parseLong(string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String representation of this object.
|
||||
* While this method informs as XML format representaion,
|
||||
* it's purpose is just information, not making
|
||||
* a rigid XML documentation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String toString() {
|
||||
try {
|
||||
return (makeTextDocument());
|
||||
} catch (Exception e) {
|
||||
return (super.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @return IRNode
|
||||
*/
|
||||
public IRNode rGetParentRNode() {
|
||||
return (parentRNode_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @param parentRNode
|
||||
*/
|
||||
public void rSetParentRNode(IRNode parentRNode) {
|
||||
this.parentRNode_ = parentRNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets child RNodes.
|
||||
*
|
||||
* @return IRNode[]
|
||||
*/
|
||||
public IRNode[] rGetRNodes() {
|
||||
List<IRNode> classNodes = new ArrayList<>();
|
||||
IRNode[] nodes = new IRNode[classNodes.size()];
|
||||
return ((IRNode[])classNodes.toArray(nodes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if a Element <code>element</code> is valid
|
||||
* for the <code>XGlyphFile</code>.
|
||||
*
|
||||
* @param element
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(Element element) {
|
||||
if (!URelaxer.isTargetElement(element, "glyphFile")) {
|
||||
return (false);
|
||||
}
|
||||
RStack target = new RStack(element);
|
||||
boolean $match$ = false;
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
Element child;
|
||||
if (!URelaxer.hasAttributeHungry(target, "href")) {
|
||||
return (false);
|
||||
}
|
||||
$match$ = true;
|
||||
if (!URelaxer.hasAttributeHungry(target, "unicode")) {
|
||||
return (false);
|
||||
}
|
||||
$match$ = true;
|
||||
if (!target.isEmptyElement()) {
|
||||
return (false);
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XGlyphFile</code>.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
return (isMatch(element));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XGlyphFile</code>.
|
||||
* This method consumes the stack contents during matching operation.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatchHungry(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
if (isMatch(element)) {
|
||||
stack.popElement();
|
||||
return (true);
|
||||
} else {
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,684 +0,0 @@
|
||||
/*
|
||||
* The Relaxer artifact
|
||||
* Copyright (c) 2000-2004, ASAMI Tomoharu, All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.doubletype.ossa.xml;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.xml.parsers.*;
|
||||
import org.w3c.dom.*;
|
||||
import org.xml.sax.*;
|
||||
|
||||
/**
|
||||
* <b>XHeadGlobal</b> is generated from glyph.rng by Relaxer.
|
||||
* This class is derived from:
|
||||
*
|
||||
* <!-- for programmer
|
||||
* <element name="global"><ref name="paramList"/></element>-->
|
||||
* <!-- for javadoc -->
|
||||
* <pre> <element name="global"><ref name="paramList"/></element></pre>
|
||||
*
|
||||
* @version glyph.rng (Tue Nov 09 20:22:48 EST 2004)
|
||||
* @author Relaxer 1.1b (http://www.relaxer.org)
|
||||
*/
|
||||
public class XHeadGlobal implements java.io.Serializable, Cloneable, IRNode {
|
||||
// List<XParamListParam>
|
||||
private List<XParamListParam> paramListParam_ = new ArrayList<>();
|
||||
private IRNode parentRNode_;
|
||||
|
||||
/**
|
||||
* Creates a <code>XHeadGlobal</code>.
|
||||
*
|
||||
*/
|
||||
public XHeadGlobal() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHeadGlobal</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public XHeadGlobal(XHeadGlobal source) {
|
||||
setup(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHeadGlobal</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public XHeadGlobal(RStack stack) {
|
||||
setup(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHeadGlobal</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public XHeadGlobal(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHeadGlobal</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public XHeadGlobal(Element element) {
|
||||
setup(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHeadGlobal</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XHeadGlobal(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHeadGlobal</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XHeadGlobal(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHeadGlobal</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XHeadGlobal(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHeadGlobal</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XHeadGlobal(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHeadGlobal</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XHeadGlobal(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(is);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHeadGlobal</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XHeadGlobal(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHeadGlobal</code> by the XHeadGlobal <code>source</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public void setup(XHeadGlobal source) {
|
||||
int size;
|
||||
this.paramListParam_.clear();
|
||||
size = source.paramListParam_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
addParamListParam((XParamListParam)source.getParamListParam(i).clone());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHeadGlobal</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public void setup(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHeadGlobal</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public void setup(Element element) {
|
||||
init(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHeadGlobal</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public void setup(RStack stack) {
|
||||
init(stack.popElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param element
|
||||
*/
|
||||
private void init(Element element) {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
RStack stack = new RStack(element);
|
||||
paramListParam_.clear();
|
||||
while (true) {
|
||||
if (XParamListParam.isMatch(stack)) {
|
||||
addParamListParam(factory.createXParamListParam(stack));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Object
|
||||
*/
|
||||
public Object clone() {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
return (factory.createXHeadGlobal((XHeadGlobal)this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM representation of the object.
|
||||
* Result is appended to the Node <code>parent</code>.
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
public void makeElement(Node parent) {
|
||||
Document doc;
|
||||
if (parent instanceof Document) {
|
||||
doc = (Document)parent;
|
||||
} else {
|
||||
doc = parent.getOwnerDocument();
|
||||
}
|
||||
Element element = doc.createElement("global");
|
||||
int size;
|
||||
size = this.paramListParam_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XParamListParam value = (XParamListParam)this.paramListParam_.get(i);
|
||||
value.makeElement(element);
|
||||
}
|
||||
parent.appendChild(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHeadGlobal</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file.toURI().toURL());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHeadGlobal</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(uri, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHeadGlobal</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHeadGlobal</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHeadGlobal</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHeadGlobal</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM document representation of the object.
|
||||
*
|
||||
* @exception ParserConfigurationException
|
||||
* @return Document
|
||||
*/
|
||||
public Document makeDocument() throws ParserConfigurationException {
|
||||
Document doc = UJAXP.makeDocument();
|
||||
makeElement(doc);
|
||||
return (doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the XParamListParam property <b>paramListParam</b>.
|
||||
*
|
||||
* @return XParamListParam[]
|
||||
*/
|
||||
public XParamListParam[] getParamListParam() {
|
||||
XParamListParam[] array = new XParamListParam[paramListParam_.size()];
|
||||
return ((XParamListParam[])paramListParam_.toArray(array));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XParamListParam property <b>paramListParam</b>.
|
||||
*
|
||||
* @param paramListParam
|
||||
*/
|
||||
public void setParamListParam(XParamListParam[] paramListParam) {
|
||||
this.paramListParam_.clear();
|
||||
for (int i = 0;i < paramListParam.length;i++) {
|
||||
addParamListParam(paramListParam[i]);
|
||||
}
|
||||
for (int i = 0;i < paramListParam.length;i++) {
|
||||
paramListParam[i].rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XParamListParam property <b>paramListParam</b>.
|
||||
*
|
||||
* @param paramListParam
|
||||
*/
|
||||
public void setParamListParam(XParamListParam paramListParam) {
|
||||
this.paramListParam_.clear();
|
||||
addParamListParam(paramListParam);
|
||||
if (paramListParam != null) {
|
||||
paramListParam.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the XParamListParam property <b>paramListParam</b>.
|
||||
*
|
||||
* @param paramListParam
|
||||
*/
|
||||
public void addParamListParam(XParamListParam paramListParam) {
|
||||
this.paramListParam_.add(paramListParam);
|
||||
if (paramListParam != null) {
|
||||
paramListParam.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the XParamListParam property <b>paramListParam</b>.
|
||||
*
|
||||
* @param paramListParam
|
||||
*/
|
||||
public void addParamListParam(XParamListParam[] paramListParam) {
|
||||
for (int i = 0;i < paramListParam.length;i++) {
|
||||
addParamListParam(paramListParam[i]);
|
||||
}
|
||||
for (int i = 0;i < paramListParam.length;i++) {
|
||||
paramListParam[i].rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets number of the XParamListParam property <b>paramListParam</b>.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public int sizeParamListParam() {
|
||||
return (paramListParam_.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the XParamListParam property <b>paramListParam</b> by index.
|
||||
*
|
||||
* @param index
|
||||
* @return XParamListParam
|
||||
*/
|
||||
public XParamListParam getParamListParam(int index) {
|
||||
return ((XParamListParam)paramListParam_.get(index));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XParamListParam property <b>paramListParam</b> by index.
|
||||
*
|
||||
* @param index
|
||||
* @param paramListParam
|
||||
*/
|
||||
public void setParamListParam(int index, XParamListParam paramListParam) {
|
||||
this.paramListParam_.set(index, paramListParam);
|
||||
if (paramListParam != null) {
|
||||
paramListParam.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the XParamListParam property <b>paramListParam</b> by index.
|
||||
*
|
||||
* @param index
|
||||
* @param paramListParam
|
||||
*/
|
||||
public void addParamListParam(int index, XParamListParam paramListParam) {
|
||||
this.paramListParam_.add(index, paramListParam);
|
||||
if (paramListParam != null) {
|
||||
paramListParam.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the XParamListParam property <b>paramListParam</b> by index.
|
||||
*
|
||||
* @param index
|
||||
*/
|
||||
public void removeParamListParam(int index) {
|
||||
this.paramListParam_.remove(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the XParamListParam property <b>paramListParam</b> by object.
|
||||
*
|
||||
* @param paramListParam
|
||||
*/
|
||||
public void removeParamListParam(XParamListParam paramListParam) {
|
||||
this.paramListParam_.remove(paramListParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the XParamListParam property <b>paramListParam</b>.
|
||||
*
|
||||
*/
|
||||
public void clearParamListParam() {
|
||||
this.paramListParam_.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String makeTextDocument() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
makeTextElement(buffer);
|
||||
return (new String(buffer));
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(StringBuffer buffer) {
|
||||
int size;
|
||||
buffer.append("<global");
|
||||
buffer.append(">");
|
||||
size = this.paramListParam_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XParamListParam value = (XParamListParam)this.paramListParam_.get(i);
|
||||
value.makeTextElement(buffer);
|
||||
}
|
||||
buffer.append("</global>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextElement(Writer buffer) throws IOException {
|
||||
int size;
|
||||
buffer.write("<global");
|
||||
buffer.write(">");
|
||||
size = this.paramListParam_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XParamListParam value = (XParamListParam)this.paramListParam_.get(i);
|
||||
value.makeTextElement(buffer);
|
||||
}
|
||||
buffer.write("</global>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(PrintWriter buffer) {
|
||||
int size;
|
||||
buffer.print("<global");
|
||||
buffer.print(">");
|
||||
size = this.paramListParam_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XParamListParam value = (XParamListParam)this.paramListParam_.get(i);
|
||||
value.makeTextElement(buffer);
|
||||
}
|
||||
buffer.print("</global>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(StringBuffer buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextAttribute(Writer buffer) throws IOException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(PrintWriter buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String representation of this object.
|
||||
* While this method informs as XML format representaion,
|
||||
* it's purpose is just information, not making
|
||||
* a rigid XML documentation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String toString() {
|
||||
try {
|
||||
return (makeTextDocument());
|
||||
} catch (Exception e) {
|
||||
return (super.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @return IRNode
|
||||
*/
|
||||
public IRNode rGetParentRNode() {
|
||||
return (parentRNode_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @param parentRNode
|
||||
*/
|
||||
public void rSetParentRNode(IRNode parentRNode) {
|
||||
this.parentRNode_ = parentRNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets child RNodes.
|
||||
*
|
||||
* @return IRNode[]
|
||||
*/
|
||||
public IRNode[] rGetRNodes() {
|
||||
List<IRNode> classNodes = new ArrayList<>();
|
||||
classNodes.addAll(paramListParam_);
|
||||
IRNode[] nodes = new IRNode[classNodes.size()];
|
||||
return ((IRNode[])classNodes.toArray(nodes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if a Element <code>element</code> is valid
|
||||
* for the <code>XHeadGlobal</code>.
|
||||
*
|
||||
* @param element
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(Element element) {
|
||||
if (!URelaxer.isTargetElement(element, "global")) {
|
||||
return (false);
|
||||
}
|
||||
RStack target = new RStack(element);
|
||||
boolean $match$ = false;
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
Element child;
|
||||
while (true) {
|
||||
if (!XParamListParam.isMatchHungry(target)) {
|
||||
break;
|
||||
}
|
||||
$match$ = true;
|
||||
}
|
||||
if (!target.isEmptyElement()) {
|
||||
return (false);
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XHeadGlobal</code>.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
return (isMatch(element));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XHeadGlobal</code>.
|
||||
* This method consumes the stack contents during matching operation.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatchHungry(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
if (isMatch(element)) {
|
||||
stack.popElement();
|
||||
return (true);
|
||||
} else {
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,684 +0,0 @@
|
||||
/*
|
||||
* The Relaxer artifact
|
||||
* Copyright (c) 2000-2004, ASAMI Tomoharu, All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.doubletype.ossa.xml;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.xml.parsers.*;
|
||||
import org.w3c.dom.*;
|
||||
import org.xml.sax.*;
|
||||
|
||||
/**
|
||||
* <b>XHeadLocal</b> is generated from glyph.rng by Relaxer.
|
||||
* This class is derived from:
|
||||
*
|
||||
* <!-- for programmer
|
||||
* <element name="local"><ref name="paramList"/></element>-->
|
||||
* <!-- for javadoc -->
|
||||
* <pre> <element name="local"><ref name="paramList"/></element></pre>
|
||||
*
|
||||
* @version glyph.rng (Tue Nov 09 20:22:48 EST 2004)
|
||||
* @author Relaxer 1.1b (http://www.relaxer.org)
|
||||
*/
|
||||
public class XHeadLocal implements java.io.Serializable, Cloneable, IRNode {
|
||||
// List<XParamListParam>
|
||||
private List<XParamListParam> paramListParam_ = new ArrayList<>();
|
||||
private IRNode parentRNode_;
|
||||
|
||||
/**
|
||||
* Creates a <code>XHeadLocal</code>.
|
||||
*
|
||||
*/
|
||||
public XHeadLocal() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHeadLocal</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public XHeadLocal(XHeadLocal source) {
|
||||
setup(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHeadLocal</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public XHeadLocal(RStack stack) {
|
||||
setup(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHeadLocal</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public XHeadLocal(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHeadLocal</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public XHeadLocal(Element element) {
|
||||
setup(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHeadLocal</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XHeadLocal(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHeadLocal</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XHeadLocal(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHeadLocal</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XHeadLocal(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHeadLocal</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XHeadLocal(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHeadLocal</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XHeadLocal(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(is);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHeadLocal</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XHeadLocal(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHeadLocal</code> by the XHeadLocal <code>source</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public void setup(XHeadLocal source) {
|
||||
int size;
|
||||
this.paramListParam_.clear();
|
||||
size = source.paramListParam_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
addParamListParam((XParamListParam)source.getParamListParam(i).clone());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHeadLocal</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public void setup(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHeadLocal</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public void setup(Element element) {
|
||||
init(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHeadLocal</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public void setup(RStack stack) {
|
||||
init(stack.popElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param element
|
||||
*/
|
||||
private void init(Element element) {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
RStack stack = new RStack(element);
|
||||
paramListParam_.clear();
|
||||
while (true) {
|
||||
if (XParamListParam.isMatch(stack)) {
|
||||
addParamListParam(factory.createXParamListParam(stack));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Object
|
||||
*/
|
||||
public Object clone() {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
return (factory.createXHeadLocal((XHeadLocal)this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM representation of the object.
|
||||
* Result is appended to the Node <code>parent</code>.
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
public void makeElement(Node parent) {
|
||||
Document doc;
|
||||
if (parent instanceof Document) {
|
||||
doc = (Document)parent;
|
||||
} else {
|
||||
doc = parent.getOwnerDocument();
|
||||
}
|
||||
Element element = doc.createElement("local");
|
||||
int size;
|
||||
size = this.paramListParam_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XParamListParam value = (XParamListParam)this.paramListParam_.get(i);
|
||||
value.makeElement(element);
|
||||
}
|
||||
parent.appendChild(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHeadLocal</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file.toURI().toURL());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHeadLocal</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(uri, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHeadLocal</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHeadLocal</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHeadLocal</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHeadLocal</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM document representation of the object.
|
||||
*
|
||||
* @exception ParserConfigurationException
|
||||
* @return Document
|
||||
*/
|
||||
public Document makeDocument() throws ParserConfigurationException {
|
||||
Document doc = UJAXP.makeDocument();
|
||||
makeElement(doc);
|
||||
return (doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the XParamListParam property <b>paramListParam</b>.
|
||||
*
|
||||
* @return XParamListParam[]
|
||||
*/
|
||||
public XParamListParam[] getParamListParam() {
|
||||
XParamListParam[] array = new XParamListParam[paramListParam_.size()];
|
||||
return ((XParamListParam[])paramListParam_.toArray(array));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XParamListParam property <b>paramListParam</b>.
|
||||
*
|
||||
* @param paramListParam
|
||||
*/
|
||||
public void setParamListParam(XParamListParam[] paramListParam) {
|
||||
this.paramListParam_.clear();
|
||||
for (int i = 0;i < paramListParam.length;i++) {
|
||||
addParamListParam(paramListParam[i]);
|
||||
}
|
||||
for (int i = 0;i < paramListParam.length;i++) {
|
||||
paramListParam[i].rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XParamListParam property <b>paramListParam</b>.
|
||||
*
|
||||
* @param paramListParam
|
||||
*/
|
||||
public void setParamListParam(XParamListParam paramListParam) {
|
||||
this.paramListParam_.clear();
|
||||
addParamListParam(paramListParam);
|
||||
if (paramListParam != null) {
|
||||
paramListParam.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the XParamListParam property <b>paramListParam</b>.
|
||||
*
|
||||
* @param paramListParam
|
||||
*/
|
||||
public void addParamListParam(XParamListParam paramListParam) {
|
||||
this.paramListParam_.add(paramListParam);
|
||||
if (paramListParam != null) {
|
||||
paramListParam.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the XParamListParam property <b>paramListParam</b>.
|
||||
*
|
||||
* @param paramListParam
|
||||
*/
|
||||
public void addParamListParam(XParamListParam[] paramListParam) {
|
||||
for (int i = 0;i < paramListParam.length;i++) {
|
||||
addParamListParam(paramListParam[i]);
|
||||
}
|
||||
for (int i = 0;i < paramListParam.length;i++) {
|
||||
paramListParam[i].rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets number of the XParamListParam property <b>paramListParam</b>.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public int sizeParamListParam() {
|
||||
return (paramListParam_.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the XParamListParam property <b>paramListParam</b> by index.
|
||||
*
|
||||
* @param index
|
||||
* @return XParamListParam
|
||||
*/
|
||||
public XParamListParam getParamListParam(int index) {
|
||||
return ((XParamListParam)paramListParam_.get(index));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XParamListParam property <b>paramListParam</b> by index.
|
||||
*
|
||||
* @param index
|
||||
* @param paramListParam
|
||||
*/
|
||||
public void setParamListParam(int index, XParamListParam paramListParam) {
|
||||
this.paramListParam_.set(index, paramListParam);
|
||||
if (paramListParam != null) {
|
||||
paramListParam.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the XParamListParam property <b>paramListParam</b> by index.
|
||||
*
|
||||
* @param index
|
||||
* @param paramListParam
|
||||
*/
|
||||
public void addParamListParam(int index, XParamListParam paramListParam) {
|
||||
this.paramListParam_.add(index, paramListParam);
|
||||
if (paramListParam != null) {
|
||||
paramListParam.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the XParamListParam property <b>paramListParam</b> by index.
|
||||
*
|
||||
* @param index
|
||||
*/
|
||||
public void removeParamListParam(int index) {
|
||||
this.paramListParam_.remove(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the XParamListParam property <b>paramListParam</b> by object.
|
||||
*
|
||||
* @param paramListParam
|
||||
*/
|
||||
public void removeParamListParam(XParamListParam paramListParam) {
|
||||
this.paramListParam_.remove(paramListParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the XParamListParam property <b>paramListParam</b>.
|
||||
*
|
||||
*/
|
||||
public void clearParamListParam() {
|
||||
this.paramListParam_.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String makeTextDocument() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
makeTextElement(buffer);
|
||||
return (new String(buffer));
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(StringBuffer buffer) {
|
||||
int size;
|
||||
buffer.append("<local");
|
||||
buffer.append(">");
|
||||
size = this.paramListParam_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XParamListParam value = (XParamListParam)this.paramListParam_.get(i);
|
||||
value.makeTextElement(buffer);
|
||||
}
|
||||
buffer.append("</local>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextElement(Writer buffer) throws IOException {
|
||||
int size;
|
||||
buffer.write("<local");
|
||||
buffer.write(">");
|
||||
size = this.paramListParam_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XParamListParam value = (XParamListParam)this.paramListParam_.get(i);
|
||||
value.makeTextElement(buffer);
|
||||
}
|
||||
buffer.write("</local>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(PrintWriter buffer) {
|
||||
int size;
|
||||
buffer.print("<local");
|
||||
buffer.print(">");
|
||||
size = this.paramListParam_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XParamListParam value = (XParamListParam)this.paramListParam_.get(i);
|
||||
value.makeTextElement(buffer);
|
||||
}
|
||||
buffer.print("</local>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(StringBuffer buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextAttribute(Writer buffer) throws IOException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(PrintWriter buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String representation of this object.
|
||||
* While this method informs as XML format representaion,
|
||||
* it's purpose is just information, not making
|
||||
* a rigid XML documentation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String toString() {
|
||||
try {
|
||||
return (makeTextDocument());
|
||||
} catch (Exception e) {
|
||||
return (super.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @return IRNode
|
||||
*/
|
||||
public IRNode rGetParentRNode() {
|
||||
return (parentRNode_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @param parentRNode
|
||||
*/
|
||||
public void rSetParentRNode(IRNode parentRNode) {
|
||||
this.parentRNode_ = parentRNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets child RNodes.
|
||||
*
|
||||
* @return IRNode[]
|
||||
*/
|
||||
public IRNode[] rGetRNodes() {
|
||||
List<IRNode> classNodes = new ArrayList<>();
|
||||
classNodes.addAll(paramListParam_);
|
||||
IRNode[] nodes = new IRNode[classNodes.size()];
|
||||
return ((IRNode[])classNodes.toArray(nodes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if a Element <code>element</code> is valid
|
||||
* for the <code>XHeadLocal</code>.
|
||||
*
|
||||
* @param element
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(Element element) {
|
||||
if (!URelaxer.isTargetElement(element, "local")) {
|
||||
return (false);
|
||||
}
|
||||
RStack target = new RStack(element);
|
||||
boolean $match$ = false;
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
Element child;
|
||||
while (true) {
|
||||
if (!XParamListParam.isMatchHungry(target)) {
|
||||
break;
|
||||
}
|
||||
$match$ = true;
|
||||
}
|
||||
if (!target.isEmptyElement()) {
|
||||
return (false);
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XHeadLocal</code>.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
return (isMatch(element));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XHeadLocal</code>.
|
||||
* This method consumes the stack contents during matching operation.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatchHungry(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
if (isMatch(element)) {
|
||||
stack.popElement();
|
||||
return (true);
|
||||
} else {
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,607 +0,0 @@
|
||||
/*
|
||||
* The Relaxer artifact
|
||||
* Copyright (c) 2000-2004, ASAMI Tomoharu, All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.doubletype.ossa.xml;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.xml.parsers.*;
|
||||
import org.w3c.dom.*;
|
||||
import org.xml.sax.*;
|
||||
|
||||
/**
|
||||
* <b>XHint</b> is generated from glyph.rng by Relaxer.
|
||||
* This class is derived from:
|
||||
*
|
||||
* <!-- for programmer
|
||||
* <element name="hint" ns="http://doubletype.org/ns/glyph/0.0">
|
||||
* <attribute name="ppem">
|
||||
* <data type="long"/>
|
||||
* </attribute>
|
||||
* <ref name="point2d"/>
|
||||
* </element>-->
|
||||
* <!-- for javadoc -->
|
||||
* <pre> <element name="hint" ns="http://doubletype.org/ns/glyph/0.0">
|
||||
* <attribute name="ppem">
|
||||
* <data type="long"/>
|
||||
* </attribute>
|
||||
* <ref name="point2d"/>
|
||||
* </element></pre>
|
||||
*
|
||||
* @version glyph.rng (Tue Nov 09 20:22:48 EST 2004)
|
||||
* @author Relaxer 1.1b (http://www.relaxer.org)
|
||||
*/
|
||||
public class XHint implements java.io.Serializable, Cloneable, IRNode {
|
||||
private long ppem_;
|
||||
private XPoint2d point2d_;
|
||||
private IRNode parentRNode_;
|
||||
|
||||
/**
|
||||
* Creates a <code>XHint</code>.
|
||||
*
|
||||
*/
|
||||
public XHint() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHint</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public XHint(XHint source) {
|
||||
setup(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHint</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public XHint(RStack stack) {
|
||||
setup(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHint</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public XHint(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHint</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public XHint(Element element) {
|
||||
setup(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHint</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XHint(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHint</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XHint(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHint</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XHint(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHint</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XHint(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHint</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XHint(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(is);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XHint</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XHint(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHint</code> by the XHint <code>source</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public void setup(XHint source) {
|
||||
int size;
|
||||
ppem_ = source.ppem_;
|
||||
if (source.point2d_ != null) {
|
||||
setPoint2d((XPoint2d)source.getPoint2d().clone());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHint</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public void setup(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHint</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public void setup(Element element) {
|
||||
init(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHint</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public void setup(RStack stack) {
|
||||
init(stack.popElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param element
|
||||
*/
|
||||
private void init(Element element) {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
RStack stack = new RStack(element);
|
||||
ppem_ = URelaxer.getAttributePropertyAsLong(element, "ppem");
|
||||
setPoint2d(factory.createXPoint2d(stack));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Object
|
||||
*/
|
||||
public Object clone() {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
return (factory.createXHint((XHint)this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM representation of the object.
|
||||
* Result is appended to the Node <code>parent</code>.
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
public void makeElement(Node parent) {
|
||||
Document doc;
|
||||
if (parent instanceof Document) {
|
||||
doc = (Document)parent;
|
||||
} else {
|
||||
doc = parent.getOwnerDocument();
|
||||
}
|
||||
Element element = doc.createElement("hint");
|
||||
int size;
|
||||
URelaxer.setAttributePropertyByLong(element, "ppem", this.ppem_);
|
||||
this.point2d_.makeElement(element);
|
||||
parent.appendChild(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHint</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file.toURI().toURL());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHint</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(uri, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHint</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHint</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHint</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XHint</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM document representation of the object.
|
||||
*
|
||||
* @exception ParserConfigurationException
|
||||
* @return Document
|
||||
*/
|
||||
public Document makeDocument() throws ParserConfigurationException {
|
||||
Document doc = UJAXP.makeDocument();
|
||||
makeElement(doc);
|
||||
return (doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the long property <b>ppem</b>.
|
||||
*
|
||||
* @return long
|
||||
*/
|
||||
public long getPpem() {
|
||||
return (ppem_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the long property <b>ppem</b>.
|
||||
*
|
||||
* @param ppem
|
||||
*/
|
||||
public void setPpem(long ppem) {
|
||||
this.ppem_ = ppem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the XPoint2d property <b>point2d</b>.
|
||||
*
|
||||
* @return XPoint2d
|
||||
*/
|
||||
public XPoint2d getPoint2d() {
|
||||
return (point2d_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XPoint2d property <b>point2d</b>.
|
||||
*
|
||||
* @param point2d
|
||||
*/
|
||||
public void setPoint2d(XPoint2d point2d) {
|
||||
this.point2d_ = point2d;
|
||||
if (point2d != null) {
|
||||
point2d.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String makeTextDocument() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
makeTextElement(buffer);
|
||||
return (new String(buffer));
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(StringBuffer buffer) {
|
||||
int size;
|
||||
buffer.append("<hint");
|
||||
buffer.append(" ppem=\"");
|
||||
buffer.append(URelaxer.getString(getPpem()));
|
||||
buffer.append("\"");
|
||||
buffer.append(">");
|
||||
point2d_.makeTextElement(buffer);
|
||||
buffer.append("</hint>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextElement(Writer buffer) throws IOException {
|
||||
int size;
|
||||
buffer.write("<hint");
|
||||
buffer.write(" ppem=\"");
|
||||
buffer.write(URelaxer.getString(getPpem()));
|
||||
buffer.write("\"");
|
||||
buffer.write(">");
|
||||
point2d_.makeTextElement(buffer);
|
||||
buffer.write("</hint>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(PrintWriter buffer) {
|
||||
int size;
|
||||
buffer.print("<hint");
|
||||
buffer.print(" ppem=\"");
|
||||
buffer.print(URelaxer.getString(getPpem()));
|
||||
buffer.print("\"");
|
||||
buffer.print(">");
|
||||
point2d_.makeTextElement(buffer);
|
||||
buffer.print("</hint>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(StringBuffer buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextAttribute(Writer buffer) throws IOException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(PrintWriter buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the property value as String.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getPpemAsString() {
|
||||
return (URelaxer.getString(getPpem()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the property value by String.
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public void setPpemByString(String string) {
|
||||
setPpem(Long.parseLong(string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String representation of this object.
|
||||
* While this method informs as XML format representaion,
|
||||
* it's purpose is just information, not making
|
||||
* a rigid XML documentation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String toString() {
|
||||
try {
|
||||
return (makeTextDocument());
|
||||
} catch (Exception e) {
|
||||
return (super.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @return IRNode
|
||||
*/
|
||||
public IRNode rGetParentRNode() {
|
||||
return (parentRNode_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @param parentRNode
|
||||
*/
|
||||
public void rSetParentRNode(IRNode parentRNode) {
|
||||
this.parentRNode_ = parentRNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets child RNodes.
|
||||
*
|
||||
* @return IRNode[]
|
||||
*/
|
||||
public IRNode[] rGetRNodes() {
|
||||
List<XPoint2d> classNodes = new ArrayList<>();
|
||||
if (point2d_ != null) {
|
||||
classNodes.add(point2d_);
|
||||
}
|
||||
IRNode[] nodes = new IRNode[classNodes.size()];
|
||||
return ((IRNode[])classNodes.toArray(nodes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if a Element <code>element</code> is valid
|
||||
* for the <code>XHint</code>.
|
||||
*
|
||||
* @param element
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(Element element) {
|
||||
if (!URelaxer.isTargetElement(element, "hint")) {
|
||||
return (false);
|
||||
}
|
||||
RStack target = new RStack(element);
|
||||
boolean $match$ = false;
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
Element child;
|
||||
if (!URelaxer.hasAttributeHungry(target, "ppem")) {
|
||||
return (false);
|
||||
}
|
||||
$match$ = true;
|
||||
if (!XPoint2d.isMatchHungry(target)) {
|
||||
return (false);
|
||||
}
|
||||
$match$ = true;
|
||||
if (!target.isEmptyElement()) {
|
||||
return (false);
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XHint</code>.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
return (isMatch(element));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XHint</code>.
|
||||
* This method consumes the stack contents during matching operation.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatchHungry(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
if (isMatch(element)) {
|
||||
stack.popElement();
|
||||
return (true);
|
||||
} else {
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,612 +0,0 @@
|
||||
/*
|
||||
* The Relaxer artifact
|
||||
* Copyright (c) 2000-2004, ASAMI Tomoharu, All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.doubletype.ossa.xml;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.xml.parsers.*;
|
||||
import org.w3c.dom.*;
|
||||
import org.xml.sax.*;
|
||||
|
||||
/**
|
||||
* <b>XInclude</b> is generated from glyph.rng by Relaxer.
|
||||
* This class is derived from:
|
||||
*
|
||||
* <!-- for programmer
|
||||
* <element name="include" ns="http://doubletype.org/ns/glyph/0.0">
|
||||
* <attribute name="href"/>
|
||||
* <ref name="invoke"/>
|
||||
* </element>-->
|
||||
* <!-- for javadoc -->
|
||||
* <pre> <element name="include" ns="http://doubletype.org/ns/glyph/0.0">
|
||||
* <attribute name="href"/>
|
||||
* <ref name="invoke"/>
|
||||
* </element></pre>
|
||||
*
|
||||
* @version glyph.rng (Tue Nov 09 20:22:48 EST 2004)
|
||||
* @author Relaxer 1.1b (http://www.relaxer.org)
|
||||
*/
|
||||
public class XInclude implements java.io.Serializable, Cloneable, IRNode {
|
||||
private String href_;
|
||||
private XInvoke invoke_;
|
||||
private IRNode parentRNode_;
|
||||
|
||||
/**
|
||||
* Creates a <code>XInclude</code>.
|
||||
*
|
||||
*/
|
||||
public XInclude() {
|
||||
href_ = "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInclude</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public XInclude(XInclude source) {
|
||||
setup(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInclude</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public XInclude(RStack stack) {
|
||||
setup(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInclude</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public XInclude(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInclude</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public XInclude(Element element) {
|
||||
setup(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInclude</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInclude(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInclude</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInclude(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInclude</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInclude(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInclude</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInclude(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInclude</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInclude(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(is);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInclude</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInclude(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInclude</code> by the XInclude <code>source</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public void setup(XInclude source) {
|
||||
int size;
|
||||
href_ = source.href_;
|
||||
if (source.invoke_ != null) {
|
||||
setInvoke((XInvoke)source.getInvoke().clone());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInclude</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public void setup(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInclude</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public void setup(Element element) {
|
||||
init(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInclude</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public void setup(RStack stack) {
|
||||
init(stack.popElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param element
|
||||
*/
|
||||
private void init(Element element) {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
RStack stack = new RStack(element);
|
||||
href_ = URelaxer.getAttributePropertyAsString(element, "href");
|
||||
setInvoke(factory.createXInvoke(stack));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Object
|
||||
*/
|
||||
public Object clone() {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
return (factory.createXInclude((XInclude)this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM representation of the object.
|
||||
* Result is appended to the Node <code>parent</code>.
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
public void makeElement(Node parent) {
|
||||
Document doc;
|
||||
if (parent instanceof Document) {
|
||||
doc = (Document)parent;
|
||||
} else {
|
||||
doc = parent.getOwnerDocument();
|
||||
}
|
||||
Element element = doc.createElement("include");
|
||||
int size;
|
||||
if (this.href_ != null) {
|
||||
URelaxer.setAttributePropertyByString(element, "href", this.href_);
|
||||
}
|
||||
this.invoke_.makeElement(element);
|
||||
parent.appendChild(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInclude</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file.toURI().toURL());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInclude</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(uri, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInclude</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInclude</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInclude</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInclude</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM document representation of the object.
|
||||
*
|
||||
* @exception ParserConfigurationException
|
||||
* @return Document
|
||||
*/
|
||||
public Document makeDocument() throws ParserConfigurationException {
|
||||
Document doc = UJAXP.makeDocument();
|
||||
makeElement(doc);
|
||||
return (doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the String property <b>href</b>.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getHref() {
|
||||
return (href_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the String property <b>href</b>.
|
||||
*
|
||||
* @param href
|
||||
*/
|
||||
public void setHref(String href) {
|
||||
this.href_ = href;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the XInvoke property <b>invoke</b>.
|
||||
*
|
||||
* @return XInvoke
|
||||
*/
|
||||
public XInvoke getInvoke() {
|
||||
return (invoke_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XInvoke property <b>invoke</b>.
|
||||
*
|
||||
* @param invoke
|
||||
*/
|
||||
public void setInvoke(XInvoke invoke) {
|
||||
this.invoke_ = invoke;
|
||||
if (invoke != null) {
|
||||
invoke.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String makeTextDocument() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
makeTextElement(buffer);
|
||||
return (new String(buffer));
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(StringBuffer buffer) {
|
||||
int size;
|
||||
buffer.append("<include");
|
||||
if (href_ != null) {
|
||||
buffer.append(" href=\"");
|
||||
buffer.append(URelaxer.escapeAttrQuot(URelaxer.getString(getHref())));
|
||||
buffer.append("\"");
|
||||
}
|
||||
buffer.append(">");
|
||||
invoke_.makeTextElement(buffer);
|
||||
buffer.append("</include>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextElement(Writer buffer) throws IOException {
|
||||
int size;
|
||||
buffer.write("<include");
|
||||
if (href_ != null) {
|
||||
buffer.write(" href=\"");
|
||||
buffer.write(URelaxer.escapeAttrQuot(URelaxer.getString(getHref())));
|
||||
buffer.write("\"");
|
||||
}
|
||||
buffer.write(">");
|
||||
invoke_.makeTextElement(buffer);
|
||||
buffer.write("</include>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(PrintWriter buffer) {
|
||||
int size;
|
||||
buffer.print("<include");
|
||||
if (href_ != null) {
|
||||
buffer.print(" href=\"");
|
||||
buffer.print(URelaxer.escapeAttrQuot(URelaxer.getString(getHref())));
|
||||
buffer.print("\"");
|
||||
}
|
||||
buffer.print(">");
|
||||
invoke_.makeTextElement(buffer);
|
||||
buffer.print("</include>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(StringBuffer buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextAttribute(Writer buffer) throws IOException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(PrintWriter buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the property value as String.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getHrefAsString() {
|
||||
return (URelaxer.getString(getHref()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the property value by String.
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public void setHrefByString(String string) {
|
||||
setHref(string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String representation of this object.
|
||||
* While this method informs as XML format representaion,
|
||||
* it's purpose is just information, not making
|
||||
* a rigid XML documentation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String toString() {
|
||||
try {
|
||||
return (makeTextDocument());
|
||||
} catch (Exception e) {
|
||||
return (super.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @return IRNode
|
||||
*/
|
||||
public IRNode rGetParentRNode() {
|
||||
return (parentRNode_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @param parentRNode
|
||||
*/
|
||||
public void rSetParentRNode(IRNode parentRNode) {
|
||||
this.parentRNode_ = parentRNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets child RNodes.
|
||||
*
|
||||
* @return IRNode[]
|
||||
*/
|
||||
public IRNode[] rGetRNodes() {
|
||||
List<IRNode> classNodes = new ArrayList<>();
|
||||
if (invoke_ != null) {
|
||||
classNodes.add(invoke_);
|
||||
}
|
||||
IRNode[] nodes = new IRNode[classNodes.size()];
|
||||
return ((IRNode[])classNodes.toArray(nodes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if a Element <code>element</code> is valid
|
||||
* for the <code>XInclude</code>.
|
||||
*
|
||||
* @param element
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(Element element) {
|
||||
if (!URelaxer.isTargetElement(element, "include")) {
|
||||
return (false);
|
||||
}
|
||||
RStack target = new RStack(element);
|
||||
boolean $match$ = false;
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
Element child;
|
||||
if (!URelaxer.hasAttributeHungry(target, "href")) {
|
||||
return (false);
|
||||
}
|
||||
$match$ = true;
|
||||
if (!XInvoke.isMatchHungry(target)) {
|
||||
return (false);
|
||||
}
|
||||
$match$ = true;
|
||||
if (!target.isEmptyElement()) {
|
||||
return (false);
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XInclude</code>.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
return (isMatch(element));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XInclude</code>.
|
||||
* This method consumes the stack contents during matching operation.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatchHungry(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
if (isMatch(element)) {
|
||||
stack.popElement();
|
||||
return (true);
|
||||
} else {
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,930 +0,0 @@
|
||||
/*
|
||||
* The Relaxer artifact
|
||||
* Copyright (c) 2000-2004, ASAMI Tomoharu, All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.doubletype.ossa.xml;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.xml.parsers.*;
|
||||
import org.w3c.dom.*;
|
||||
import org.xml.sax.*;
|
||||
|
||||
/**
|
||||
* <b>XInvoke</b> is generated from glyph.rng by Relaxer.
|
||||
* This class is derived from:
|
||||
*
|
||||
* <!-- for programmer
|
||||
* <element name="invoke" ns="http://doubletype.org/ns/glyph/0.0">
|
||||
* <element name="pos">
|
||||
* <ref name="point2d"/>
|
||||
* </element>
|
||||
* <zeroOrMore>
|
||||
* <element name="arg">
|
||||
* <attribute name="name"/>
|
||||
* <data type="double"/>
|
||||
* </element>
|
||||
* </zeroOrMore>
|
||||
* <zeroOrMore>
|
||||
* <element name="varg">
|
||||
* <attribute name="name"/>
|
||||
* <attribute name="src"/>
|
||||
* </element>
|
||||
* </zeroOrMore>
|
||||
* </element>-->
|
||||
* <!-- for javadoc -->
|
||||
* <pre> <element name="invoke" ns="http://doubletype.org/ns/glyph/0.0">
|
||||
* <element name="pos">
|
||||
* <ref name="point2d"/>
|
||||
* </element>
|
||||
* <zeroOrMore>
|
||||
* <element name="arg">
|
||||
* <attribute name="name"/>
|
||||
* <data type="double"/>
|
||||
* </element>
|
||||
* </zeroOrMore>
|
||||
* <zeroOrMore>
|
||||
* <element name="varg">
|
||||
* <attribute name="name"/>
|
||||
* <attribute name="src"/>
|
||||
* </element>
|
||||
* </zeroOrMore>
|
||||
* </element></pre>
|
||||
*
|
||||
* @version glyph.rng (Tue Nov 09 20:22:48 EST 2004)
|
||||
* @author Relaxer 1.1b (http://www.relaxer.org)
|
||||
*/
|
||||
public class XInvoke implements java.io.Serializable, Cloneable, IRNode {
|
||||
private XInvokePos invokePos_;
|
||||
// List<XInvokeArg>
|
||||
private List<XInvokeArg> invokeArg_ = new ArrayList<>();
|
||||
// List<XInvokeVarg>
|
||||
private List<XInvokeVarg> invokeVarg_ = new ArrayList<>();
|
||||
private IRNode parentRNode_;
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvoke</code>.
|
||||
*
|
||||
*/
|
||||
public XInvoke() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvoke</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public XInvoke(XInvoke source) {
|
||||
setup(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvoke</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public XInvoke(RStack stack) {
|
||||
setup(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvoke</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public XInvoke(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvoke</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public XInvoke(Element element) {
|
||||
setup(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvoke</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInvoke(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvoke</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInvoke(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvoke</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInvoke(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvoke</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInvoke(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvoke</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInvoke(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(is);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvoke</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInvoke(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvoke</code> by the XInvoke <code>source</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public void setup(XInvoke source) {
|
||||
int size;
|
||||
if (source.invokePos_ != null) {
|
||||
setInvokePos((XInvokePos)source.getInvokePos().clone());
|
||||
}
|
||||
this.invokeArg_.clear();
|
||||
size = source.invokeArg_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
addInvokeArg((XInvokeArg)source.getInvokeArg(i).clone());
|
||||
}
|
||||
this.invokeVarg_.clear();
|
||||
size = source.invokeVarg_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
addInvokeVarg((XInvokeVarg)source.getInvokeVarg(i).clone());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvoke</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public void setup(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvoke</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public void setup(Element element) {
|
||||
init(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvoke</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public void setup(RStack stack) {
|
||||
init(stack.popElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param element
|
||||
*/
|
||||
private void init(Element element) {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
RStack stack = new RStack(element);
|
||||
setInvokePos(factory.createXInvokePos(stack));
|
||||
invokeArg_.clear();
|
||||
while (true) {
|
||||
if (XInvokeArg.isMatch(stack)) {
|
||||
addInvokeArg(factory.createXInvokeArg(stack));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
invokeVarg_.clear();
|
||||
while (true) {
|
||||
if (XInvokeVarg.isMatch(stack)) {
|
||||
addInvokeVarg(factory.createXInvokeVarg(stack));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Object
|
||||
*/
|
||||
public Object clone() {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
return (factory.createXInvoke((XInvoke)this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM representation of the object.
|
||||
* Result is appended to the Node <code>parent</code>.
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
public void makeElement(Node parent) {
|
||||
Document doc;
|
||||
if (parent instanceof Document) {
|
||||
doc = (Document)parent;
|
||||
} else {
|
||||
doc = parent.getOwnerDocument();
|
||||
}
|
||||
Element element = doc.createElement("invoke");
|
||||
int size;
|
||||
this.invokePos_.makeElement(element);
|
||||
size = this.invokeArg_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XInvokeArg value = (XInvokeArg)this.invokeArg_.get(i);
|
||||
value.makeElement(element);
|
||||
}
|
||||
size = this.invokeVarg_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XInvokeVarg value = (XInvokeVarg)this.invokeVarg_.get(i);
|
||||
value.makeElement(element);
|
||||
}
|
||||
parent.appendChild(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvoke</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file.toURI().toURL());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvoke</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(uri, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvoke</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvoke</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvoke</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvoke</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM document representation of the object.
|
||||
*
|
||||
* @exception ParserConfigurationException
|
||||
* @return Document
|
||||
*/
|
||||
public Document makeDocument() throws ParserConfigurationException {
|
||||
Document doc = UJAXP.makeDocument();
|
||||
makeElement(doc);
|
||||
return (doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the XInvokePos property <b>invokePos</b>.
|
||||
*
|
||||
* @return XInvokePos
|
||||
*/
|
||||
public XInvokePos getInvokePos() {
|
||||
return (invokePos_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XInvokePos property <b>invokePos</b>.
|
||||
*
|
||||
* @param invokePos
|
||||
*/
|
||||
public void setInvokePos(XInvokePos invokePos) {
|
||||
this.invokePos_ = invokePos;
|
||||
if (invokePos != null) {
|
||||
invokePos.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the XInvokeArg property <b>invokeArg</b>.
|
||||
*
|
||||
* @return XInvokeArg[]
|
||||
*/
|
||||
public XInvokeArg[] getInvokeArg() {
|
||||
XInvokeArg[] array = new XInvokeArg[invokeArg_.size()];
|
||||
return ((XInvokeArg[])invokeArg_.toArray(array));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XInvokeArg property <b>invokeArg</b>.
|
||||
*
|
||||
* @param invokeArg
|
||||
*/
|
||||
public void setInvokeArg(XInvokeArg[] invokeArg) {
|
||||
this.invokeArg_.clear();
|
||||
for (int i = 0;i < invokeArg.length;i++) {
|
||||
addInvokeArg(invokeArg[i]);
|
||||
}
|
||||
for (int i = 0;i < invokeArg.length;i++) {
|
||||
invokeArg[i].rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XInvokeArg property <b>invokeArg</b>.
|
||||
*
|
||||
* @param invokeArg
|
||||
*/
|
||||
public void setInvokeArg(XInvokeArg invokeArg) {
|
||||
this.invokeArg_.clear();
|
||||
addInvokeArg(invokeArg);
|
||||
if (invokeArg != null) {
|
||||
invokeArg.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the XInvokeArg property <b>invokeArg</b>.
|
||||
*
|
||||
* @param invokeArg
|
||||
*/
|
||||
public void addInvokeArg(XInvokeArg invokeArg) {
|
||||
this.invokeArg_.add(invokeArg);
|
||||
if (invokeArg != null) {
|
||||
invokeArg.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the XInvokeArg property <b>invokeArg</b>.
|
||||
*
|
||||
* @param invokeArg
|
||||
*/
|
||||
public void addInvokeArg(XInvokeArg[] invokeArg) {
|
||||
for (int i = 0;i < invokeArg.length;i++) {
|
||||
addInvokeArg(invokeArg[i]);
|
||||
}
|
||||
for (int i = 0;i < invokeArg.length;i++) {
|
||||
invokeArg[i].rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets number of the XInvokeArg property <b>invokeArg</b>.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public int sizeInvokeArg() {
|
||||
return (invokeArg_.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the XInvokeArg property <b>invokeArg</b> by index.
|
||||
*
|
||||
* @param index
|
||||
* @return XInvokeArg
|
||||
*/
|
||||
public XInvokeArg getInvokeArg(int index) {
|
||||
return ((XInvokeArg)invokeArg_.get(index));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XInvokeArg property <b>invokeArg</b> by index.
|
||||
*
|
||||
* @param index
|
||||
* @param invokeArg
|
||||
*/
|
||||
public void setInvokeArg(int index, XInvokeArg invokeArg) {
|
||||
this.invokeArg_.set(index, invokeArg);
|
||||
if (invokeArg != null) {
|
||||
invokeArg.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the XInvokeArg property <b>invokeArg</b> by index.
|
||||
*
|
||||
* @param index
|
||||
* @param invokeArg
|
||||
*/
|
||||
public void addInvokeArg(int index, XInvokeArg invokeArg) {
|
||||
this.invokeArg_.add(index, invokeArg);
|
||||
if (invokeArg != null) {
|
||||
invokeArg.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the XInvokeArg property <b>invokeArg</b> by index.
|
||||
*
|
||||
* @param index
|
||||
*/
|
||||
public void removeInvokeArg(int index) {
|
||||
this.invokeArg_.remove(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the XInvokeArg property <b>invokeArg</b> by object.
|
||||
*
|
||||
* @param invokeArg
|
||||
*/
|
||||
public void removeInvokeArg(XInvokeArg invokeArg) {
|
||||
this.invokeArg_.remove(invokeArg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the XInvokeArg property <b>invokeArg</b>.
|
||||
*
|
||||
*/
|
||||
public void clearInvokeArg() {
|
||||
this.invokeArg_.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the XInvokeVarg property <b>invokeVarg</b>.
|
||||
*
|
||||
* @return XInvokeVarg[]
|
||||
*/
|
||||
public XInvokeVarg[] getInvokeVarg() {
|
||||
XInvokeVarg[] array = new XInvokeVarg[invokeVarg_.size()];
|
||||
return ((XInvokeVarg[])invokeVarg_.toArray(array));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XInvokeVarg property <b>invokeVarg</b>.
|
||||
*
|
||||
* @param invokeVarg
|
||||
*/
|
||||
public void setInvokeVarg(XInvokeVarg[] invokeVarg) {
|
||||
this.invokeVarg_.clear();
|
||||
for (int i = 0;i < invokeVarg.length;i++) {
|
||||
addInvokeVarg(invokeVarg[i]);
|
||||
}
|
||||
for (int i = 0;i < invokeVarg.length;i++) {
|
||||
invokeVarg[i].rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XInvokeVarg property <b>invokeVarg</b>.
|
||||
*
|
||||
* @param invokeVarg
|
||||
*/
|
||||
public void setInvokeVarg(XInvokeVarg invokeVarg) {
|
||||
this.invokeVarg_.clear();
|
||||
addInvokeVarg(invokeVarg);
|
||||
if (invokeVarg != null) {
|
||||
invokeVarg.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the XInvokeVarg property <b>invokeVarg</b>.
|
||||
*
|
||||
* @param invokeVarg
|
||||
*/
|
||||
public void addInvokeVarg(XInvokeVarg invokeVarg) {
|
||||
this.invokeVarg_.add(invokeVarg);
|
||||
if (invokeVarg != null) {
|
||||
invokeVarg.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the XInvokeVarg property <b>invokeVarg</b>.
|
||||
*
|
||||
* @param invokeVarg
|
||||
*/
|
||||
public void addInvokeVarg(XInvokeVarg[] invokeVarg) {
|
||||
for (int i = 0;i < invokeVarg.length;i++) {
|
||||
addInvokeVarg(invokeVarg[i]);
|
||||
}
|
||||
for (int i = 0;i < invokeVarg.length;i++) {
|
||||
invokeVarg[i].rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets number of the XInvokeVarg property <b>invokeVarg</b>.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public int sizeInvokeVarg() {
|
||||
return (invokeVarg_.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the XInvokeVarg property <b>invokeVarg</b> by index.
|
||||
*
|
||||
* @param index
|
||||
* @return XInvokeVarg
|
||||
*/
|
||||
public XInvokeVarg getInvokeVarg(int index) {
|
||||
return ((XInvokeVarg)invokeVarg_.get(index));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XInvokeVarg property <b>invokeVarg</b> by index.
|
||||
*
|
||||
* @param index
|
||||
* @param invokeVarg
|
||||
*/
|
||||
public void setInvokeVarg(int index, XInvokeVarg invokeVarg) {
|
||||
this.invokeVarg_.set(index, invokeVarg);
|
||||
if (invokeVarg != null) {
|
||||
invokeVarg.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the XInvokeVarg property <b>invokeVarg</b> by index.
|
||||
*
|
||||
* @param index
|
||||
* @param invokeVarg
|
||||
*/
|
||||
public void addInvokeVarg(int index, XInvokeVarg invokeVarg) {
|
||||
this.invokeVarg_.add(index, invokeVarg);
|
||||
if (invokeVarg != null) {
|
||||
invokeVarg.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the XInvokeVarg property <b>invokeVarg</b> by index.
|
||||
*
|
||||
* @param index
|
||||
*/
|
||||
public void removeInvokeVarg(int index) {
|
||||
this.invokeVarg_.remove(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the XInvokeVarg property <b>invokeVarg</b> by object.
|
||||
*
|
||||
* @param invokeVarg
|
||||
*/
|
||||
public void removeInvokeVarg(XInvokeVarg invokeVarg) {
|
||||
this.invokeVarg_.remove(invokeVarg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the XInvokeVarg property <b>invokeVarg</b>.
|
||||
*
|
||||
*/
|
||||
public void clearInvokeVarg() {
|
||||
this.invokeVarg_.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String makeTextDocument() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
makeTextElement(buffer);
|
||||
return (new String(buffer));
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(StringBuffer buffer) {
|
||||
int size;
|
||||
buffer.append("<invoke");
|
||||
buffer.append(">");
|
||||
invokePos_.makeTextElement(buffer);
|
||||
size = this.invokeArg_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XInvokeArg value = (XInvokeArg)this.invokeArg_.get(i);
|
||||
value.makeTextElement(buffer);
|
||||
}
|
||||
size = this.invokeVarg_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XInvokeVarg value = (XInvokeVarg)this.invokeVarg_.get(i);
|
||||
value.makeTextElement(buffer);
|
||||
}
|
||||
buffer.append("</invoke>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextElement(Writer buffer) throws IOException {
|
||||
int size;
|
||||
buffer.write("<invoke");
|
||||
buffer.write(">");
|
||||
invokePos_.makeTextElement(buffer);
|
||||
size = this.invokeArg_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XInvokeArg value = (XInvokeArg)this.invokeArg_.get(i);
|
||||
value.makeTextElement(buffer);
|
||||
}
|
||||
size = this.invokeVarg_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XInvokeVarg value = (XInvokeVarg)this.invokeVarg_.get(i);
|
||||
value.makeTextElement(buffer);
|
||||
}
|
||||
buffer.write("</invoke>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(PrintWriter buffer) {
|
||||
int size;
|
||||
buffer.print("<invoke");
|
||||
buffer.print(">");
|
||||
invokePos_.makeTextElement(buffer);
|
||||
size = this.invokeArg_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XInvokeArg value = (XInvokeArg)this.invokeArg_.get(i);
|
||||
value.makeTextElement(buffer);
|
||||
}
|
||||
size = this.invokeVarg_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XInvokeVarg value = (XInvokeVarg)this.invokeVarg_.get(i);
|
||||
value.makeTextElement(buffer);
|
||||
}
|
||||
buffer.print("</invoke>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(StringBuffer buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextAttribute(Writer buffer) throws IOException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(PrintWriter buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String representation of this object.
|
||||
* While this method informs as XML format representaion,
|
||||
* it's purpose is just information, not making
|
||||
* a rigid XML documentation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String toString() {
|
||||
try {
|
||||
return (makeTextDocument());
|
||||
} catch (Exception e) {
|
||||
return (super.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @return IRNode
|
||||
*/
|
||||
public IRNode rGetParentRNode() {
|
||||
return (parentRNode_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @param parentRNode
|
||||
*/
|
||||
public void rSetParentRNode(IRNode parentRNode) {
|
||||
this.parentRNode_ = parentRNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets child RNodes.
|
||||
*
|
||||
* @return IRNode[]
|
||||
*/
|
||||
public IRNode[] rGetRNodes() {
|
||||
List<IRNode> classNodes = new ArrayList<>();
|
||||
if (invokePos_ != null) {
|
||||
classNodes.add(invokePos_);
|
||||
}
|
||||
classNodes.addAll(invokeArg_);
|
||||
classNodes.addAll(invokeVarg_);
|
||||
IRNode[] nodes = new IRNode[classNodes.size()];
|
||||
return ((IRNode[])classNodes.toArray(nodes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if a Element <code>element</code> is valid
|
||||
* for the <code>XInvoke</code>.
|
||||
*
|
||||
* @param element
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(Element element) {
|
||||
if (!URelaxer.isTargetElement(element, "invoke")) {
|
||||
return (false);
|
||||
}
|
||||
RStack target = new RStack(element);
|
||||
boolean $match$ = false;
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
Element child;
|
||||
if (!XInvokePos.isMatchHungry(target)) {
|
||||
return (false);
|
||||
}
|
||||
$match$ = true;
|
||||
while (true) {
|
||||
if (!XInvokeArg.isMatchHungry(target)) {
|
||||
break;
|
||||
}
|
||||
$match$ = true;
|
||||
}
|
||||
while (true) {
|
||||
if (!XInvokeVarg.isMatchHungry(target)) {
|
||||
break;
|
||||
}
|
||||
$match$ = true;
|
||||
}
|
||||
if (!target.isEmptyElement()) {
|
||||
return (false);
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XInvoke</code>.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
return (isMatch(element));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XInvoke</code>.
|
||||
* This method consumes the stack contents during matching operation.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatchHungry(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
if (isMatch(element)) {
|
||||
stack.popElement();
|
||||
return (true);
|
||||
} else {
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,618 +0,0 @@
|
||||
/*
|
||||
* The Relaxer artifact
|
||||
* Copyright (c) 2000-2004, ASAMI Tomoharu, All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.doubletype.ossa.xml;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.xml.parsers.*;
|
||||
import org.w3c.dom.*;
|
||||
import org.xml.sax.*;
|
||||
|
||||
/**
|
||||
* <b>XInvokeArg</b> is generated from glyph.rng by Relaxer.
|
||||
* This class is derived from:
|
||||
*
|
||||
* <!-- for programmer
|
||||
* <element name="arg">
|
||||
* <attribute name="name"/>
|
||||
* <data type="double"/>
|
||||
* </element>-->
|
||||
* <!-- for javadoc -->
|
||||
* <pre> <element name="arg">
|
||||
* <attribute name="name"/>
|
||||
* <data type="double"/>
|
||||
* </element></pre>
|
||||
*
|
||||
* @version glyph.rng (Tue Nov 09 20:22:48 EST 2004)
|
||||
* @author Relaxer 1.1b (http://www.relaxer.org)
|
||||
*/
|
||||
public class XInvokeArg implements java.io.Serializable, Cloneable, IRNode {
|
||||
private double content_;
|
||||
private String name_;
|
||||
private IRNode parentRNode_;
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokeArg</code>.
|
||||
*
|
||||
*/
|
||||
public XInvokeArg() {
|
||||
name_ = "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokeArg</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public XInvokeArg(XInvokeArg source) {
|
||||
setup(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokeArg</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public XInvokeArg(RStack stack) {
|
||||
setup(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokeArg</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public XInvokeArg(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokeArg</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public XInvokeArg(Element element) {
|
||||
setup(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokeArg</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInvokeArg(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokeArg</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInvokeArg(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokeArg</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInvokeArg(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokeArg</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInvokeArg(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokeArg</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInvokeArg(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(is);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokeArg</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInvokeArg(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokeArg</code> by the XInvokeArg <code>source</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public void setup(XInvokeArg source) {
|
||||
int size;
|
||||
content_ = source.content_;
|
||||
name_ = source.name_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokeArg</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public void setup(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokeArg</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public void setup(Element element) {
|
||||
init(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokeArg</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public void setup(RStack stack) {
|
||||
init(stack.popElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param element
|
||||
*/
|
||||
private void init(Element element) {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
RStack stack = new RStack(element);
|
||||
content_ = URelaxer.getElementPropertyAsDouble(element);
|
||||
name_ = URelaxer.getAttributePropertyAsString(element, "name");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Object
|
||||
*/
|
||||
public Object clone() {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
return (factory.createXInvokeArg((XInvokeArg)this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM representation of the object.
|
||||
* Result is appended to the Node <code>parent</code>.
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
public void makeElement(Node parent) {
|
||||
Document doc;
|
||||
if (parent instanceof Document) {
|
||||
doc = (Document)parent;
|
||||
} else {
|
||||
doc = parent.getOwnerDocument();
|
||||
}
|
||||
Element element = doc.createElement("arg");
|
||||
URelaxer.setElementPropertyByDouble(element, this.content_);
|
||||
int size;
|
||||
if (this.name_ != null) {
|
||||
URelaxer.setAttributePropertyByString(element, "name", this.name_);
|
||||
}
|
||||
parent.appendChild(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokeArg</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file.toURI().toURL());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokeArg</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(uri, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokeArg</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokeArg</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokeArg</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokeArg</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM document representation of the object.
|
||||
*
|
||||
* @exception ParserConfigurationException
|
||||
* @return Document
|
||||
*/
|
||||
public Document makeDocument() throws ParserConfigurationException {
|
||||
Document doc = UJAXP.makeDocument();
|
||||
makeElement(doc);
|
||||
return (doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the double property <b>content</b>.
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
public double getContent() {
|
||||
return (content_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the double property <b>content</b>.
|
||||
*
|
||||
* @param content
|
||||
*/
|
||||
public void setContent(double content) {
|
||||
this.content_ = content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the String property <b>name</b>.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getName() {
|
||||
return (name_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the String property <b>name</b>.
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name_ = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String makeTextDocument() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
makeTextElement(buffer);
|
||||
return (new String(buffer));
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(StringBuffer buffer) {
|
||||
int size;
|
||||
buffer.append("<arg");
|
||||
if (name_ != null) {
|
||||
buffer.append(" name=\"");
|
||||
buffer.append(URelaxer.escapeAttrQuot(URelaxer.getString(getName())));
|
||||
buffer.append("\"");
|
||||
}
|
||||
buffer.append(">");
|
||||
buffer.append(URelaxer.getString(getContent()));
|
||||
buffer.append("</arg>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextElement(Writer buffer) throws IOException {
|
||||
int size;
|
||||
buffer.write("<arg");
|
||||
if (name_ != null) {
|
||||
buffer.write(" name=\"");
|
||||
buffer.write(URelaxer.escapeAttrQuot(URelaxer.getString(getName())));
|
||||
buffer.write("\"");
|
||||
}
|
||||
buffer.write(">");
|
||||
buffer.write(URelaxer.getString(getContent()));
|
||||
buffer.write("</arg>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(PrintWriter buffer) {
|
||||
int size;
|
||||
buffer.print("<arg");
|
||||
if (name_ != null) {
|
||||
buffer.print(" name=\"");
|
||||
buffer.print(URelaxer.escapeAttrQuot(URelaxer.getString(getName())));
|
||||
buffer.print("\"");
|
||||
}
|
||||
buffer.print(">");
|
||||
buffer.print(URelaxer.getString(getContent()));
|
||||
buffer.print("</arg>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(StringBuffer buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextAttribute(Writer buffer) throws IOException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(PrintWriter buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the property value as String.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getContentAsString() {
|
||||
return (URelaxer.getString(getContent()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the property value as String.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getNameAsString() {
|
||||
return (URelaxer.getString(getName()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the property value by String.
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public void setContentByString(String string) {
|
||||
setContent(Double.parseDouble(string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the property value by String.
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public void setNameByString(String string) {
|
||||
setName(string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String representation of this object.
|
||||
* While this method informs as XML format representaion,
|
||||
* it's purpose is just information, not making
|
||||
* a rigid XML documentation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String toString() {
|
||||
try {
|
||||
return (makeTextDocument());
|
||||
} catch (Exception e) {
|
||||
return (super.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @return IRNode
|
||||
*/
|
||||
public IRNode rGetParentRNode() {
|
||||
return (parentRNode_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @param parentRNode
|
||||
*/
|
||||
public void rSetParentRNode(IRNode parentRNode) {
|
||||
this.parentRNode_ = parentRNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets child RNodes.
|
||||
*
|
||||
* @return IRNode[]
|
||||
*/
|
||||
public IRNode[] rGetRNodes() {
|
||||
List<IRNode> classNodes = new ArrayList<>();
|
||||
IRNode[] nodes = new IRNode[classNodes.size()];
|
||||
return ((IRNode[])classNodes.toArray(nodes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if a Element <code>element</code> is valid
|
||||
* for the <code>XInvokeArg</code>.
|
||||
*
|
||||
* @param element
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(Element element) {
|
||||
if (!URelaxer.isTargetElement(element, "arg")) {
|
||||
return (false);
|
||||
}
|
||||
RStack target = new RStack(element);
|
||||
boolean $match$ = false;
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
Element child;
|
||||
if (!URelaxer.hasAttributeHungry(target, "name")) {
|
||||
return (false);
|
||||
}
|
||||
$match$ = true;
|
||||
if (!target.isEmptyElement()) {
|
||||
return (false);
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XInvokeArg</code>.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
return (isMatch(element));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XInvokeArg</code>.
|
||||
* This method consumes the stack contents during matching operation.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatchHungry(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
if (isMatch(element)) {
|
||||
stack.popElement();
|
||||
return (true);
|
||||
} else {
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,548 +0,0 @@
|
||||
/*
|
||||
* The Relaxer artifact
|
||||
* Copyright (c) 2000-2004, ASAMI Tomoharu, All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.doubletype.ossa.xml;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.xml.parsers.*;
|
||||
import org.w3c.dom.*;
|
||||
import org.xml.sax.*;
|
||||
|
||||
/**
|
||||
* <b>XInvokePos</b> is generated from glyph.rng by Relaxer.
|
||||
* This class is derived from:
|
||||
*
|
||||
* <!-- for programmer
|
||||
* <element name="pos">
|
||||
* <ref name="point2d"/>
|
||||
* </element>-->
|
||||
* <!-- for javadoc -->
|
||||
* <pre> <element name="pos">
|
||||
* <ref name="point2d"/>
|
||||
* </element></pre>
|
||||
*
|
||||
* @version glyph.rng (Tue Nov 09 20:22:48 EST 2004)
|
||||
* @author Relaxer 1.1b (http://www.relaxer.org)
|
||||
*/
|
||||
public class XInvokePos implements java.io.Serializable, Cloneable, IRNode {
|
||||
private XPoint2d point2d_;
|
||||
private IRNode parentRNode_;
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokePos</code>.
|
||||
*
|
||||
*/
|
||||
public XInvokePos() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokePos</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public XInvokePos(XInvokePos source) {
|
||||
setup(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokePos</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public XInvokePos(RStack stack) {
|
||||
setup(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokePos</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public XInvokePos(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokePos</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public XInvokePos(Element element) {
|
||||
setup(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokePos</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInvokePos(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokePos</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInvokePos(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokePos</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInvokePos(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokePos</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInvokePos(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokePos</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInvokePos(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(is);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokePos</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInvokePos(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokePos</code> by the XInvokePos <code>source</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public void setup(XInvokePos source) {
|
||||
int size;
|
||||
if (source.point2d_ != null) {
|
||||
setPoint2d((XPoint2d)source.getPoint2d().clone());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokePos</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public void setup(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokePos</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public void setup(Element element) {
|
||||
init(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokePos</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public void setup(RStack stack) {
|
||||
init(stack.popElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param element
|
||||
*/
|
||||
private void init(Element element) {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
RStack stack = new RStack(element);
|
||||
setPoint2d(factory.createXPoint2d(stack));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Object
|
||||
*/
|
||||
public Object clone() {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
return (factory.createXInvokePos((XInvokePos)this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM representation of the object.
|
||||
* Result is appended to the Node <code>parent</code>.
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
public void makeElement(Node parent) {
|
||||
Document doc;
|
||||
if (parent instanceof Document) {
|
||||
doc = (Document)parent;
|
||||
} else {
|
||||
doc = parent.getOwnerDocument();
|
||||
}
|
||||
Element element = doc.createElement("pos");
|
||||
int size;
|
||||
this.point2d_.makeElement(element);
|
||||
parent.appendChild(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokePos</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file.toURI().toURL());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokePos</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(uri, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokePos</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokePos</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokePos</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokePos</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM document representation of the object.
|
||||
*
|
||||
* @exception ParserConfigurationException
|
||||
* @return Document
|
||||
*/
|
||||
public Document makeDocument() throws ParserConfigurationException {
|
||||
Document doc = UJAXP.makeDocument();
|
||||
makeElement(doc);
|
||||
return (doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the XPoint2d property <b>point2d</b>.
|
||||
*
|
||||
* @return XPoint2d
|
||||
*/
|
||||
public XPoint2d getPoint2d() {
|
||||
return (point2d_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XPoint2d property <b>point2d</b>.
|
||||
*
|
||||
* @param point2d
|
||||
*/
|
||||
public void setPoint2d(XPoint2d point2d) {
|
||||
this.point2d_ = point2d;
|
||||
if (point2d != null) {
|
||||
point2d.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String makeTextDocument() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
makeTextElement(buffer);
|
||||
return (new String(buffer));
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(StringBuffer buffer) {
|
||||
int size;
|
||||
buffer.append("<pos");
|
||||
buffer.append(">");
|
||||
point2d_.makeTextElement(buffer);
|
||||
buffer.append("</pos>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextElement(Writer buffer) throws IOException {
|
||||
int size;
|
||||
buffer.write("<pos");
|
||||
buffer.write(">");
|
||||
point2d_.makeTextElement(buffer);
|
||||
buffer.write("</pos>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(PrintWriter buffer) {
|
||||
int size;
|
||||
buffer.print("<pos");
|
||||
buffer.print(">");
|
||||
point2d_.makeTextElement(buffer);
|
||||
buffer.print("</pos>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(StringBuffer buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextAttribute(Writer buffer) throws IOException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(PrintWriter buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String representation of this object.
|
||||
* While this method informs as XML format representaion,
|
||||
* it's purpose is just information, not making
|
||||
* a rigid XML documentation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String toString() {
|
||||
try {
|
||||
return (makeTextDocument());
|
||||
} catch (Exception e) {
|
||||
return (super.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @return IRNode
|
||||
*/
|
||||
public IRNode rGetParentRNode() {
|
||||
return (parentRNode_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @param parentRNode
|
||||
*/
|
||||
public void rSetParentRNode(IRNode parentRNode) {
|
||||
this.parentRNode_ = parentRNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets child RNodes.
|
||||
*
|
||||
* @return IRNode[]
|
||||
*/
|
||||
public IRNode[] rGetRNodes() {
|
||||
List<IRNode> classNodes = new ArrayList<>();
|
||||
if (point2d_ != null) {
|
||||
classNodes.add(point2d_);
|
||||
}
|
||||
IRNode[] nodes = new IRNode[classNodes.size()];
|
||||
return ((IRNode[])classNodes.toArray(nodes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if a Element <code>element</code> is valid
|
||||
* for the <code>XInvokePos</code>.
|
||||
*
|
||||
* @param element
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(Element element) {
|
||||
if (!URelaxer.isTargetElement(element, "pos")) {
|
||||
return (false);
|
||||
}
|
||||
RStack target = new RStack(element);
|
||||
boolean $match$ = false;
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
Element child;
|
||||
if (!XPoint2d.isMatchHungry(target)) {
|
||||
return (false);
|
||||
}
|
||||
$match$ = true;
|
||||
if (!target.isEmptyElement()) {
|
||||
return (false);
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XInvokePos</code>.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
return (isMatch(element));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XInvokePos</code>.
|
||||
* This method consumes the stack contents during matching operation.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatchHungry(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
if (isMatch(element)) {
|
||||
stack.popElement();
|
||||
return (true);
|
||||
} else {
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,637 +0,0 @@
|
||||
/*
|
||||
* The Relaxer artifact
|
||||
* Copyright (c) 2000-2004, ASAMI Tomoharu, All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.doubletype.ossa.xml;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.xml.parsers.*;
|
||||
import org.w3c.dom.*;
|
||||
import org.xml.sax.*;
|
||||
|
||||
/**
|
||||
* <b>XInvokeVarg</b> is generated from glyph.rng by Relaxer.
|
||||
* This class is derived from:
|
||||
*
|
||||
* <!-- for programmer
|
||||
* <element name="varg">
|
||||
* <attribute name="name"/>
|
||||
* <attribute name="src"/>
|
||||
* </element>-->
|
||||
* <!-- for javadoc -->
|
||||
* <pre> <element name="varg">
|
||||
* <attribute name="name"/>
|
||||
* <attribute name="src"/>
|
||||
* </element></pre>
|
||||
*
|
||||
* @version glyph.rng (Tue Nov 09 20:22:48 EST 2004)
|
||||
* @author Relaxer 1.1b (http://www.relaxer.org)
|
||||
*/
|
||||
public class XInvokeVarg implements java.io.Serializable, Cloneable, IRNode {
|
||||
private String name_;
|
||||
private String src_;
|
||||
private IRNode parentRNode_;
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokeVarg</code>.
|
||||
*
|
||||
*/
|
||||
public XInvokeVarg() {
|
||||
name_ = "";
|
||||
src_ = "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokeVarg</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public XInvokeVarg(XInvokeVarg source) {
|
||||
setup(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokeVarg</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public XInvokeVarg(RStack stack) {
|
||||
setup(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokeVarg</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public XInvokeVarg(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokeVarg</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public XInvokeVarg(Element element) {
|
||||
setup(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokeVarg</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInvokeVarg(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokeVarg</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInvokeVarg(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokeVarg</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInvokeVarg(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokeVarg</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInvokeVarg(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokeVarg</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInvokeVarg(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(is);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XInvokeVarg</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XInvokeVarg(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokeVarg</code> by the XInvokeVarg <code>source</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public void setup(XInvokeVarg source) {
|
||||
int size;
|
||||
name_ = source.name_;
|
||||
src_ = source.src_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokeVarg</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public void setup(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokeVarg</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public void setup(Element element) {
|
||||
init(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokeVarg</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public void setup(RStack stack) {
|
||||
init(stack.popElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param element
|
||||
*/
|
||||
private void init(Element element) {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
RStack stack = new RStack(element);
|
||||
name_ = URelaxer.getAttributePropertyAsString(element, "name");
|
||||
src_ = URelaxer.getAttributePropertyAsString(element, "src");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Object
|
||||
*/
|
||||
public Object clone() {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
return (factory.createXInvokeVarg((XInvokeVarg)this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM representation of the object.
|
||||
* Result is appended to the Node <code>parent</code>.
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
public void makeElement(Node parent) {
|
||||
Document doc;
|
||||
if (parent instanceof Document) {
|
||||
doc = (Document)parent;
|
||||
} else {
|
||||
doc = parent.getOwnerDocument();
|
||||
}
|
||||
Element element = doc.createElement("varg");
|
||||
int size;
|
||||
if (this.name_ != null) {
|
||||
URelaxer.setAttributePropertyByString(element, "name", this.name_);
|
||||
}
|
||||
if (this.src_ != null) {
|
||||
URelaxer.setAttributePropertyByString(element, "src", this.src_);
|
||||
}
|
||||
parent.appendChild(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokeVarg</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file.toURI().toURL());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokeVarg</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(uri, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokeVarg</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokeVarg</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokeVarg</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XInvokeVarg</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM document representation of the object.
|
||||
*
|
||||
* @exception ParserConfigurationException
|
||||
* @return Document
|
||||
*/
|
||||
public Document makeDocument() throws ParserConfigurationException {
|
||||
Document doc = UJAXP.makeDocument();
|
||||
makeElement(doc);
|
||||
return (doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the String property <b>name</b>.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getName() {
|
||||
return (name_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the String property <b>name</b>.
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name_ = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the String property <b>src</b>.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getSrc() {
|
||||
return (src_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the String property <b>src</b>.
|
||||
*
|
||||
* @param src
|
||||
*/
|
||||
public void setSrc(String src) {
|
||||
this.src_ = src;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String makeTextDocument() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
makeTextElement(buffer);
|
||||
return (new String(buffer));
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(StringBuffer buffer) {
|
||||
int size;
|
||||
buffer.append("<varg");
|
||||
if (name_ != null) {
|
||||
buffer.append(" name=\"");
|
||||
buffer.append(URelaxer.escapeAttrQuot(URelaxer.getString(getName())));
|
||||
buffer.append("\"");
|
||||
}
|
||||
if (src_ != null) {
|
||||
buffer.append(" src=\"");
|
||||
buffer.append(URelaxer.escapeAttrQuot(URelaxer.getString(getSrc())));
|
||||
buffer.append("\"");
|
||||
}
|
||||
buffer.append(">");
|
||||
buffer.append("</varg>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextElement(Writer buffer) throws IOException {
|
||||
int size;
|
||||
buffer.write("<varg");
|
||||
if (name_ != null) {
|
||||
buffer.write(" name=\"");
|
||||
buffer.write(URelaxer.escapeAttrQuot(URelaxer.getString(getName())));
|
||||
buffer.write("\"");
|
||||
}
|
||||
if (src_ != null) {
|
||||
buffer.write(" src=\"");
|
||||
buffer.write(URelaxer.escapeAttrQuot(URelaxer.getString(getSrc())));
|
||||
buffer.write("\"");
|
||||
}
|
||||
buffer.write(">");
|
||||
buffer.write("</varg>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(PrintWriter buffer) {
|
||||
int size;
|
||||
buffer.print("<varg");
|
||||
if (name_ != null) {
|
||||
buffer.print(" name=\"");
|
||||
buffer.print(URelaxer.escapeAttrQuot(URelaxer.getString(getName())));
|
||||
buffer.print("\"");
|
||||
}
|
||||
if (src_ != null) {
|
||||
buffer.print(" src=\"");
|
||||
buffer.print(URelaxer.escapeAttrQuot(URelaxer.getString(getSrc())));
|
||||
buffer.print("\"");
|
||||
}
|
||||
buffer.print(">");
|
||||
buffer.print("</varg>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(StringBuffer buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextAttribute(Writer buffer) throws IOException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(PrintWriter buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the property value as String.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getNameAsString() {
|
||||
return (URelaxer.getString(getName()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the property value as String.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getSrcAsString() {
|
||||
return (URelaxer.getString(getSrc()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the property value by String.
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public void setNameByString(String string) {
|
||||
setName(string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the property value by String.
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public void setSrcByString(String string) {
|
||||
setSrc(string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String representation of this object.
|
||||
* While this method informs as XML format representaion,
|
||||
* it's purpose is just information, not making
|
||||
* a rigid XML documentation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String toString() {
|
||||
try {
|
||||
return (makeTextDocument());
|
||||
} catch (Exception e) {
|
||||
return (super.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @return IRNode
|
||||
*/
|
||||
public IRNode rGetParentRNode() {
|
||||
return (parentRNode_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @param parentRNode
|
||||
*/
|
||||
public void rSetParentRNode(IRNode parentRNode) {
|
||||
this.parentRNode_ = parentRNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets child RNodes.
|
||||
*
|
||||
* @return IRNode[]
|
||||
*/
|
||||
public IRNode[] rGetRNodes() {
|
||||
List<IRNode> classNodes = new ArrayList<>();
|
||||
IRNode[] nodes = new IRNode[classNodes.size()];
|
||||
return ((IRNode[])classNodes.toArray(nodes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if a Element <code>element</code> is valid
|
||||
* for the <code>XInvokeVarg</code>.
|
||||
*
|
||||
* @param element
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(Element element) {
|
||||
if (!URelaxer.isTargetElement(element, "varg")) {
|
||||
return (false);
|
||||
}
|
||||
RStack target = new RStack(element);
|
||||
boolean $match$ = false;
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
Element child;
|
||||
if (!URelaxer.hasAttributeHungry(target, "name")) {
|
||||
return (false);
|
||||
}
|
||||
$match$ = true;
|
||||
if (!URelaxer.hasAttributeHungry(target, "src")) {
|
||||
return (false);
|
||||
}
|
||||
$match$ = true;
|
||||
if (!target.isEmptyElement()) {
|
||||
return (false);
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XInvokeVarg</code>.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
return (isMatch(element));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XInvokeVarg</code>.
|
||||
* This method consumes the stack contents during matching operation.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatchHungry(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
if (isMatch(element)) {
|
||||
stack.popElement();
|
||||
return (true);
|
||||
} else {
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,799 +0,0 @@
|
||||
/*
|
||||
* The Relaxer artifact
|
||||
* Copyright (c) 2000-2004, ASAMI Tomoharu, All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.doubletype.ossa.xml;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.xml.parsers.*;
|
||||
import org.w3c.dom.*;
|
||||
import org.xml.sax.*;
|
||||
|
||||
/**
|
||||
* <b>XModule</b> is generated from glyph.rng by Relaxer.
|
||||
* This class is derived from:
|
||||
*
|
||||
* <!-- for programmer
|
||||
* <element name="module" ns="http://doubletype.org/ns/glyph/0.0">
|
||||
* <attribute name="name"/>
|
||||
* <ref name="invoke"/>
|
||||
* <oneOrMore>
|
||||
* <ref name="contourPoint"/>
|
||||
* </oneOrMore>
|
||||
* </element>-->
|
||||
* <!-- for javadoc -->
|
||||
* <pre> <element name="module" ns="http://doubletype.org/ns/glyph/0.0">
|
||||
* <attribute name="name"/>
|
||||
* <ref name="invoke"/>
|
||||
* <oneOrMore>
|
||||
* <ref name="contourPoint"/>
|
||||
* </oneOrMore>
|
||||
* </element></pre>
|
||||
*
|
||||
* @version glyph.rng (Tue Nov 09 20:22:48 EST 2004)
|
||||
* @author Relaxer 1.1b (http://www.relaxer.org)
|
||||
*/
|
||||
public class XModule implements java.io.Serializable, Cloneable, IRNode {
|
||||
private String name_;
|
||||
private XInvoke invoke_;
|
||||
// List<XContourPoint>
|
||||
private List<XContourPoint> contourPoint_ = new ArrayList<>();
|
||||
private IRNode parentRNode_;
|
||||
|
||||
/**
|
||||
* Creates a <code>XModule</code>.
|
||||
*
|
||||
*/
|
||||
public XModule() {
|
||||
name_ = "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XModule</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public XModule(XModule source) {
|
||||
setup(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XModule</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public XModule(RStack stack) {
|
||||
setup(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XModule</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public XModule(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XModule</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public XModule(Element element) {
|
||||
setup(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XModule</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XModule(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XModule</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XModule(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XModule</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XModule(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XModule</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XModule(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XModule</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XModule(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(is);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XModule</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XModule(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XModule</code> by the XModule <code>source</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public void setup(XModule source) {
|
||||
int size;
|
||||
name_ = source.name_;
|
||||
if (source.invoke_ != null) {
|
||||
setInvoke((XInvoke)source.getInvoke().clone());
|
||||
}
|
||||
this.contourPoint_.clear();
|
||||
size = source.contourPoint_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
addContourPoint((XContourPoint)source.getContourPoint(i).clone());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XModule</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public void setup(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XModule</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public void setup(Element element) {
|
||||
init(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XModule</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public void setup(RStack stack) {
|
||||
init(stack.popElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param element
|
||||
*/
|
||||
private void init(Element element) {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
RStack stack = new RStack(element);
|
||||
name_ = URelaxer.getAttributePropertyAsString(element, "name");
|
||||
setInvoke(factory.createXInvoke(stack));
|
||||
contourPoint_.clear();
|
||||
while (true) {
|
||||
if (XContourPoint.isMatch(stack)) {
|
||||
addContourPoint(factory.createXContourPoint(stack));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Object
|
||||
*/
|
||||
public Object clone() {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
return (factory.createXModule((XModule)this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM representation of the object.
|
||||
* Result is appended to the Node <code>parent</code>.
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
public void makeElement(Node parent) {
|
||||
Document doc;
|
||||
if (parent instanceof Document) {
|
||||
doc = (Document)parent;
|
||||
} else {
|
||||
doc = parent.getOwnerDocument();
|
||||
}
|
||||
Element element = doc.createElement("module");
|
||||
int size;
|
||||
if (this.name_ != null) {
|
||||
URelaxer.setAttributePropertyByString(element, "name", this.name_);
|
||||
}
|
||||
this.invoke_.makeElement(element);
|
||||
size = this.contourPoint_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XContourPoint value = (XContourPoint)this.contourPoint_.get(i);
|
||||
value.makeElement(element);
|
||||
}
|
||||
parent.appendChild(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XModule</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file.toURI().toURL());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XModule</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(uri, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XModule</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XModule</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XModule</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XModule</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM document representation of the object.
|
||||
*
|
||||
* @exception ParserConfigurationException
|
||||
* @return Document
|
||||
*/
|
||||
public Document makeDocument() throws ParserConfigurationException {
|
||||
Document doc = UJAXP.makeDocument();
|
||||
makeElement(doc);
|
||||
return (doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the String property <b>name</b>.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getName() {
|
||||
return (name_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the String property <b>name</b>.
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name_ = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the XInvoke property <b>invoke</b>.
|
||||
*
|
||||
* @return XInvoke
|
||||
*/
|
||||
public XInvoke getInvoke() {
|
||||
return (invoke_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XInvoke property <b>invoke</b>.
|
||||
*
|
||||
* @param invoke
|
||||
*/
|
||||
public void setInvoke(XInvoke invoke) {
|
||||
this.invoke_ = invoke;
|
||||
if (invoke != null) {
|
||||
invoke.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the XContourPoint property <b>contourPoint</b>.
|
||||
*
|
||||
* @return XContourPoint[]
|
||||
*/
|
||||
public XContourPoint[] getContourPoint() {
|
||||
XContourPoint[] array = new XContourPoint[contourPoint_.size()];
|
||||
return ((XContourPoint[])contourPoint_.toArray(array));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XContourPoint property <b>contourPoint</b>.
|
||||
*
|
||||
* @param contourPoint
|
||||
*/
|
||||
public void setContourPoint(XContourPoint[] contourPoint) {
|
||||
this.contourPoint_.clear();
|
||||
for (int i = 0;i < contourPoint.length;i++) {
|
||||
addContourPoint(contourPoint[i]);
|
||||
}
|
||||
for (int i = 0;i < contourPoint.length;i++) {
|
||||
contourPoint[i].rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XContourPoint property <b>contourPoint</b>.
|
||||
*
|
||||
* @param contourPoint
|
||||
*/
|
||||
public void setContourPoint(XContourPoint contourPoint) {
|
||||
this.contourPoint_.clear();
|
||||
addContourPoint(contourPoint);
|
||||
if (contourPoint != null) {
|
||||
contourPoint.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the XContourPoint property <b>contourPoint</b>.
|
||||
*
|
||||
* @param contourPoint
|
||||
*/
|
||||
public void addContourPoint(XContourPoint contourPoint) {
|
||||
this.contourPoint_.add(contourPoint);
|
||||
if (contourPoint != null) {
|
||||
contourPoint.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the XContourPoint property <b>contourPoint</b>.
|
||||
*
|
||||
* @param contourPoint
|
||||
*/
|
||||
public void addContourPoint(XContourPoint[] contourPoint) {
|
||||
for (int i = 0;i < contourPoint.length;i++) {
|
||||
addContourPoint(contourPoint[i]);
|
||||
}
|
||||
for (int i = 0;i < contourPoint.length;i++) {
|
||||
contourPoint[i].rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets number of the XContourPoint property <b>contourPoint</b>.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public int sizeContourPoint() {
|
||||
return (contourPoint_.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the XContourPoint property <b>contourPoint</b> by index.
|
||||
*
|
||||
* @param index
|
||||
* @return XContourPoint
|
||||
*/
|
||||
public XContourPoint getContourPoint(int index) {
|
||||
return ((XContourPoint)contourPoint_.get(index));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XContourPoint property <b>contourPoint</b> by index.
|
||||
*
|
||||
* @param index
|
||||
* @param contourPoint
|
||||
*/
|
||||
public void setContourPoint(int index, XContourPoint contourPoint) {
|
||||
this.contourPoint_.set(index, contourPoint);
|
||||
if (contourPoint != null) {
|
||||
contourPoint.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the XContourPoint property <b>contourPoint</b> by index.
|
||||
*
|
||||
* @param index
|
||||
* @param contourPoint
|
||||
*/
|
||||
public void addContourPoint(int index, XContourPoint contourPoint) {
|
||||
this.contourPoint_.add(index, contourPoint);
|
||||
if (contourPoint != null) {
|
||||
contourPoint.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the XContourPoint property <b>contourPoint</b> by index.
|
||||
*
|
||||
* @param index
|
||||
*/
|
||||
public void removeContourPoint(int index) {
|
||||
this.contourPoint_.remove(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the XContourPoint property <b>contourPoint</b> by object.
|
||||
*
|
||||
* @param contourPoint
|
||||
*/
|
||||
public void removeContourPoint(XContourPoint contourPoint) {
|
||||
this.contourPoint_.remove(contourPoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the XContourPoint property <b>contourPoint</b>.
|
||||
*
|
||||
*/
|
||||
public void clearContourPoint() {
|
||||
this.contourPoint_.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String makeTextDocument() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
makeTextElement(buffer);
|
||||
return (new String(buffer));
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(StringBuffer buffer) {
|
||||
int size;
|
||||
buffer.append("<module");
|
||||
if (name_ != null) {
|
||||
buffer.append(" name=\"");
|
||||
buffer.append(URelaxer.escapeAttrQuot(URelaxer.getString(getName())));
|
||||
buffer.append("\"");
|
||||
}
|
||||
buffer.append(">");
|
||||
invoke_.makeTextElement(buffer);
|
||||
size = this.contourPoint_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XContourPoint value = (XContourPoint)this.contourPoint_.get(i);
|
||||
value.makeTextElement(buffer);
|
||||
}
|
||||
buffer.append("</module>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextElement(Writer buffer) throws IOException {
|
||||
int size;
|
||||
buffer.write("<module");
|
||||
if (name_ != null) {
|
||||
buffer.write(" name=\"");
|
||||
buffer.write(URelaxer.escapeAttrQuot(URelaxer.getString(getName())));
|
||||
buffer.write("\"");
|
||||
}
|
||||
buffer.write(">");
|
||||
invoke_.makeTextElement(buffer);
|
||||
size = this.contourPoint_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XContourPoint value = (XContourPoint)this.contourPoint_.get(i);
|
||||
value.makeTextElement(buffer);
|
||||
}
|
||||
buffer.write("</module>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(PrintWriter buffer) {
|
||||
int size;
|
||||
buffer.print("<module");
|
||||
if (name_ != null) {
|
||||
buffer.print(" name=\"");
|
||||
buffer.print(URelaxer.escapeAttrQuot(URelaxer.getString(getName())));
|
||||
buffer.print("\"");
|
||||
}
|
||||
buffer.print(">");
|
||||
invoke_.makeTextElement(buffer);
|
||||
size = this.contourPoint_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XContourPoint value = (XContourPoint)this.contourPoint_.get(i);
|
||||
value.makeTextElement(buffer);
|
||||
}
|
||||
buffer.print("</module>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(StringBuffer buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextAttribute(Writer buffer) throws IOException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(PrintWriter buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the property value as String.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getNameAsString() {
|
||||
return (URelaxer.getString(getName()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the property value by String.
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public void setNameByString(String string) {
|
||||
setName(string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String representation of this object.
|
||||
* While this method informs as XML format representaion,
|
||||
* it's purpose is just information, not making
|
||||
* a rigid XML documentation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String toString() {
|
||||
try {
|
||||
return (makeTextDocument());
|
||||
} catch (Exception e) {
|
||||
return (super.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @return IRNode
|
||||
*/
|
||||
public IRNode rGetParentRNode() {
|
||||
return (parentRNode_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @param parentRNode
|
||||
*/
|
||||
public void rSetParentRNode(IRNode parentRNode) {
|
||||
this.parentRNode_ = parentRNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets child RNodes.
|
||||
*
|
||||
* @return IRNode[]
|
||||
*/
|
||||
public IRNode[] rGetRNodes() {
|
||||
List<IRNode> classNodes = new ArrayList<>();
|
||||
if (invoke_ != null) {
|
||||
classNodes.add(invoke_);
|
||||
}
|
||||
classNodes.addAll(contourPoint_);
|
||||
IRNode[] nodes = new IRNode[classNodes.size()];
|
||||
return ((IRNode[])classNodes.toArray(nodes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if a Element <code>element</code> is valid
|
||||
* for the <code>XModule</code>.
|
||||
*
|
||||
* @param element
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(Element element) {
|
||||
if (!URelaxer.isTargetElement(element, "module")) {
|
||||
return (false);
|
||||
}
|
||||
RStack target = new RStack(element);
|
||||
boolean $match$ = false;
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
Element child;
|
||||
if (!URelaxer.hasAttributeHungry(target, "name")) {
|
||||
return (false);
|
||||
}
|
||||
$match$ = true;
|
||||
if (!XInvoke.isMatchHungry(target)) {
|
||||
return (false);
|
||||
}
|
||||
$match$ = true;
|
||||
if (!XContourPoint.isMatchHungry(target)) {
|
||||
return (false);
|
||||
}
|
||||
$match$ = true;
|
||||
while (true) {
|
||||
if (!XContourPoint.isMatchHungry(target)) {
|
||||
break;
|
||||
}
|
||||
$match$ = true;
|
||||
}
|
||||
if (!target.isEmptyElement()) {
|
||||
return (false);
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XModule</code>.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
return (isMatch(element));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XModule</code>.
|
||||
* This method consumes the stack contents during matching operation.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatchHungry(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
if (isMatch(element)) {
|
||||
stack.popElement();
|
||||
return (true);
|
||||
} else {
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,452 +0,0 @@
|
||||
/*
|
||||
* The Relaxer artifact
|
||||
* Copyright (c) 2000-2004, ASAMI Tomoharu, All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.doubletype.ossa.xml;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.w3c.dom.*;
|
||||
|
||||
/**
|
||||
* <b>XParamList</b> is generated from glyph.rng by Relaxer.
|
||||
* This class is derived from:
|
||||
*
|
||||
* <!-- for programmer
|
||||
* <define name="paramList">
|
||||
* <zeroOrMore>
|
||||
* <element name="param" ns="http://doubletype.org/ns/glyph/0.0">
|
||||
* <attribute name="name"/>
|
||||
* <data type="double"/>
|
||||
* </element>
|
||||
* </zeroOrMore>
|
||||
* </define>-->
|
||||
* <!-- for javadoc -->
|
||||
* <pre> <define name="paramList">
|
||||
* <zeroOrMore>
|
||||
* <element name="param" ns="http://doubletype.org/ns/glyph/0.0">
|
||||
* <attribute name="name"/>
|
||||
* <data type="double"/>
|
||||
* </element>
|
||||
* </zeroOrMore>
|
||||
* </define></pre>
|
||||
*
|
||||
* @version glyph.rng (Tue Nov 09 20:22:48 EST 2004)
|
||||
* @author Relaxer 1.1b (http://www.relaxer.org)
|
||||
*/
|
||||
public class XParamList implements java.io.Serializable, Cloneable, IRNode {
|
||||
// List<XParamListParam>
|
||||
private List<XParamListParam> paramListParam_ = new ArrayList<>();
|
||||
private IRNode parentRNode_;
|
||||
|
||||
/**
|
||||
* Creates a <code>XParamList</code>.
|
||||
*
|
||||
*/
|
||||
public XParamList() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XParamList</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public XParamList(XParamList source) {
|
||||
setup(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XParamList</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public XParamList(RStack stack) {
|
||||
setup(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XParamList</code> by the XParamList <code>source</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public void setup(XParamList source) {
|
||||
int size;
|
||||
this.paramListParam_.clear();
|
||||
size = source.paramListParam_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
addParamListParam((XParamListParam)source.getParamListParam(i).clone());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XParamList</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public void setup(RStack stack) {
|
||||
Element element = stack.getContextElement();
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
paramListParam_.clear();
|
||||
while (true) {
|
||||
if (XParamListParam.isMatch(stack)) {
|
||||
addParamListParam(factory.createXParamListParam(stack));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Object
|
||||
*/
|
||||
public Object clone() {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
return (factory.createXParamList((XParamList)this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM representation of the object.
|
||||
* Result is appended to the Node <code>parent</code>.
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
public void makeElement(Node parent) {
|
||||
Document doc = parent.getOwnerDocument();
|
||||
Element element = (Element)parent;
|
||||
int size;
|
||||
size = this.paramListParam_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XParamListParam value = (XParamListParam)this.paramListParam_.get(i);
|
||||
value.makeElement(element);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the XParamListParam property <b>paramListParam</b>.
|
||||
*
|
||||
* @return XParamListParam[]
|
||||
*/
|
||||
public XParamListParam[] getParamListParam() {
|
||||
XParamListParam[] array = new XParamListParam[paramListParam_.size()];
|
||||
return ((XParamListParam[])paramListParam_.toArray(array));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XParamListParam property <b>paramListParam</b>.
|
||||
*
|
||||
* @param paramListParam
|
||||
*/
|
||||
public void setParamListParam(XParamListParam[] paramListParam) {
|
||||
this.paramListParam_.clear();
|
||||
for (int i = 0;i < paramListParam.length;i++) {
|
||||
addParamListParam(paramListParam[i]);
|
||||
}
|
||||
for (int i = 0;i < paramListParam.length;i++) {
|
||||
paramListParam[i].rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XParamListParam property <b>paramListParam</b>.
|
||||
*
|
||||
* @param paramListParam
|
||||
*/
|
||||
public void setParamListParam(XParamListParam paramListParam) {
|
||||
this.paramListParam_.clear();
|
||||
addParamListParam(paramListParam);
|
||||
if (paramListParam != null) {
|
||||
paramListParam.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the XParamListParam property <b>paramListParam</b>.
|
||||
*
|
||||
* @param paramListParam
|
||||
*/
|
||||
public void addParamListParam(XParamListParam paramListParam) {
|
||||
this.paramListParam_.add(paramListParam);
|
||||
if (paramListParam != null) {
|
||||
paramListParam.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the XParamListParam property <b>paramListParam</b>.
|
||||
*
|
||||
* @param paramListParam
|
||||
*/
|
||||
public void addParamListParam(XParamListParam[] paramListParam) {
|
||||
for (int i = 0;i < paramListParam.length;i++) {
|
||||
addParamListParam(paramListParam[i]);
|
||||
}
|
||||
for (int i = 0;i < paramListParam.length;i++) {
|
||||
paramListParam[i].rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets number of the XParamListParam property <b>paramListParam</b>.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public int sizeParamListParam() {
|
||||
return (paramListParam_.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the XParamListParam property <b>paramListParam</b> by index.
|
||||
*
|
||||
* @param index
|
||||
* @return XParamListParam
|
||||
*/
|
||||
public XParamListParam getParamListParam(int index) {
|
||||
return ((XParamListParam)paramListParam_.get(index));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XParamListParam property <b>paramListParam</b> by index.
|
||||
*
|
||||
* @param index
|
||||
* @param paramListParam
|
||||
*/
|
||||
public void setParamListParam(int index, XParamListParam paramListParam) {
|
||||
this.paramListParam_.set(index, paramListParam);
|
||||
if (paramListParam != null) {
|
||||
paramListParam.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the XParamListParam property <b>paramListParam</b> by index.
|
||||
*
|
||||
* @param index
|
||||
* @param paramListParam
|
||||
*/
|
||||
public void addParamListParam(int index, XParamListParam paramListParam) {
|
||||
this.paramListParam_.add(index, paramListParam);
|
||||
if (paramListParam != null) {
|
||||
paramListParam.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the XParamListParam property <b>paramListParam</b> by index.
|
||||
*
|
||||
* @param index
|
||||
*/
|
||||
public void removeParamListParam(int index) {
|
||||
this.paramListParam_.remove(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the XParamListParam property <b>paramListParam</b> by object.
|
||||
*
|
||||
* @param paramListParam
|
||||
*/
|
||||
public void removeParamListParam(XParamListParam paramListParam) {
|
||||
this.paramListParam_.remove(paramListParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the XParamListParam property <b>paramListParam</b>.
|
||||
*
|
||||
*/
|
||||
public void clearParamListParam() {
|
||||
this.paramListParam_.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String makeTextDocument() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
makeTextElement(buffer);
|
||||
return (new String(buffer));
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(StringBuffer buffer) {
|
||||
int size;
|
||||
size = this.paramListParam_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XParamListParam value = (XParamListParam)this.paramListParam_.get(i);
|
||||
value.makeTextElement(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextElement(Writer buffer) throws IOException {
|
||||
int size;
|
||||
size = this.paramListParam_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XParamListParam value = (XParamListParam)this.paramListParam_.get(i);
|
||||
value.makeTextElement(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(PrintWriter buffer) {
|
||||
int size;
|
||||
size = this.paramListParam_.size();
|
||||
for (int i = 0;i < size;i++) {
|
||||
XParamListParam value = (XParamListParam)this.paramListParam_.get(i);
|
||||
value.makeTextElement(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(StringBuffer buffer) {
|
||||
int size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextAttribute(Writer buffer) throws IOException {
|
||||
int size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(PrintWriter buffer) {
|
||||
int size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String representation of this object.
|
||||
* While this method informs as XML format representaion,
|
||||
* it's purpose is just information, not making
|
||||
* a rigid XML documentation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String toString() {
|
||||
try {
|
||||
return (makeTextDocument());
|
||||
} catch (Exception e) {
|
||||
return (super.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @return IRNode
|
||||
*/
|
||||
public IRNode rGetParentRNode() {
|
||||
return (parentRNode_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @param parentRNode
|
||||
*/
|
||||
public void rSetParentRNode(IRNode parentRNode) {
|
||||
this.parentRNode_ = parentRNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets child RNodes.
|
||||
*
|
||||
* @return IRNode[]
|
||||
*/
|
||||
public IRNode[] rGetRNodes() {
|
||||
List<IRNode> classNodes = new ArrayList<>();
|
||||
classNodes.addAll(paramListParam_);
|
||||
IRNode[] nodes = new IRNode[classNodes.size()];
|
||||
return ((IRNode[])classNodes.toArray(nodes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XParamList</code>.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(RStack stack) {
|
||||
return (isMatchHungry(stack.makeClone()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XParamList</code>.
|
||||
* This method consumes the stack contents during matching operation.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatchHungry(RStack stack) {
|
||||
RStack target = stack;
|
||||
boolean $match$ = false;
|
||||
Element element = stack.peekElement();
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
Element child;
|
||||
while (true) {
|
||||
if (!XParamListParam.isMatchHungry(target)) {
|
||||
break;
|
||||
}
|
||||
$match$ = true;
|
||||
}
|
||||
return ($match$);
|
||||
}
|
||||
}
|
||||
@@ -1,618 +0,0 @@
|
||||
/*
|
||||
* The Relaxer artifact
|
||||
* Copyright (c) 2000-2004, ASAMI Tomoharu, All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.doubletype.ossa.xml;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.xml.parsers.*;
|
||||
import org.w3c.dom.*;
|
||||
import org.xml.sax.*;
|
||||
|
||||
/**
|
||||
* <b>XParamListParam</b> is generated from glyph.rng by Relaxer.
|
||||
* This class is derived from:
|
||||
*
|
||||
* <!-- for programmer
|
||||
* <element name="param" ns="http://doubletype.org/ns/glyph/0.0">
|
||||
* <attribute name="name"/>
|
||||
* <data type="double"/>
|
||||
* </element>-->
|
||||
* <!-- for javadoc -->
|
||||
* <pre> <element name="param" ns="http://doubletype.org/ns/glyph/0.0">
|
||||
* <attribute name="name"/>
|
||||
* <data type="double"/>
|
||||
* </element></pre>
|
||||
*
|
||||
* @version glyph.rng (Tue Nov 09 20:22:48 EST 2004)
|
||||
* @author Relaxer 1.1b (http://www.relaxer.org)
|
||||
*/
|
||||
public class XParamListParam implements java.io.Serializable, Cloneable, IRNode {
|
||||
private double content_;
|
||||
private String name_;
|
||||
private IRNode parentRNode_;
|
||||
|
||||
/**
|
||||
* Creates a <code>XParamListParam</code>.
|
||||
*
|
||||
*/
|
||||
public XParamListParam() {
|
||||
name_ = "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XParamListParam</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public XParamListParam(XParamListParam source) {
|
||||
setup(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XParamListParam</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public XParamListParam(RStack stack) {
|
||||
setup(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XParamListParam</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public XParamListParam(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XParamListParam</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public XParamListParam(Element element) {
|
||||
setup(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XParamListParam</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XParamListParam(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XParamListParam</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XParamListParam(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XParamListParam</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XParamListParam(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XParamListParam</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XParamListParam(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XParamListParam</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XParamListParam(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(is);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XParamListParam</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XParamListParam(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XParamListParam</code> by the XParamListParam <code>source</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public void setup(XParamListParam source) {
|
||||
int size;
|
||||
content_ = source.content_;
|
||||
name_ = source.name_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XParamListParam</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public void setup(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XParamListParam</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public void setup(Element element) {
|
||||
init(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XParamListParam</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public void setup(RStack stack) {
|
||||
init(stack.popElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param element
|
||||
*/
|
||||
private void init(Element element) {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
RStack stack = new RStack(element);
|
||||
content_ = URelaxer.getElementPropertyAsDouble(element);
|
||||
name_ = URelaxer.getAttributePropertyAsString(element, "name");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Object
|
||||
*/
|
||||
public Object clone() {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
return (factory.createXParamListParam((XParamListParam)this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM representation of the object.
|
||||
* Result is appended to the Node <code>parent</code>.
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
public void makeElement(Node parent) {
|
||||
Document doc;
|
||||
if (parent instanceof Document) {
|
||||
doc = (Document)parent;
|
||||
} else {
|
||||
doc = parent.getOwnerDocument();
|
||||
}
|
||||
Element element = doc.createElement("param");
|
||||
URelaxer.setElementPropertyByDouble(element, this.content_);
|
||||
int size;
|
||||
if (this.name_ != null) {
|
||||
URelaxer.setAttributePropertyByString(element, "name", this.name_);
|
||||
}
|
||||
parent.appendChild(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XParamListParam</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file.toURI().toURL());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XParamListParam</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(uri, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XParamListParam</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XParamListParam</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XParamListParam</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XParamListParam</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM document representation of the object.
|
||||
*
|
||||
* @exception ParserConfigurationException
|
||||
* @return Document
|
||||
*/
|
||||
public Document makeDocument() throws ParserConfigurationException {
|
||||
Document doc = UJAXP.makeDocument();
|
||||
makeElement(doc);
|
||||
return (doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the double property <b>content</b>.
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
public double getContent() {
|
||||
return (content_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the double property <b>content</b>.
|
||||
*
|
||||
* @param content
|
||||
*/
|
||||
public void setContent(double content) {
|
||||
this.content_ = content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the String property <b>name</b>.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getName() {
|
||||
return (name_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the String property <b>name</b>.
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name_ = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String makeTextDocument() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
makeTextElement(buffer);
|
||||
return (new String(buffer));
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(StringBuffer buffer) {
|
||||
int size;
|
||||
buffer.append("<param");
|
||||
if (name_ != null) {
|
||||
buffer.append(" name=\"");
|
||||
buffer.append(URelaxer.escapeAttrQuot(URelaxer.getString(getName())));
|
||||
buffer.append("\"");
|
||||
}
|
||||
buffer.append(">");
|
||||
buffer.append(URelaxer.getString(getContent()));
|
||||
buffer.append("</param>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextElement(Writer buffer) throws IOException {
|
||||
int size;
|
||||
buffer.write("<param");
|
||||
if (name_ != null) {
|
||||
buffer.write(" name=\"");
|
||||
buffer.write(URelaxer.escapeAttrQuot(URelaxer.getString(getName())));
|
||||
buffer.write("\"");
|
||||
}
|
||||
buffer.write(">");
|
||||
buffer.write(URelaxer.getString(getContent()));
|
||||
buffer.write("</param>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(PrintWriter buffer) {
|
||||
int size;
|
||||
buffer.print("<param");
|
||||
if (name_ != null) {
|
||||
buffer.print(" name=\"");
|
||||
buffer.print(URelaxer.escapeAttrQuot(URelaxer.getString(getName())));
|
||||
buffer.print("\"");
|
||||
}
|
||||
buffer.print(">");
|
||||
buffer.print(URelaxer.getString(getContent()));
|
||||
buffer.print("</param>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(StringBuffer buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextAttribute(Writer buffer) throws IOException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(PrintWriter buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the property value as String.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getContentAsString() {
|
||||
return (URelaxer.getString(getContent()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the property value as String.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getNameAsString() {
|
||||
return (URelaxer.getString(getName()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the property value by String.
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public void setContentByString(String string) {
|
||||
setContent(Double.parseDouble(string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the property value by String.
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public void setNameByString(String string) {
|
||||
setName(string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String representation of this object.
|
||||
* While this method informs as XML format representaion,
|
||||
* it's purpose is just information, not making
|
||||
* a rigid XML documentation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String toString() {
|
||||
try {
|
||||
return (makeTextDocument());
|
||||
} catch (Exception e) {
|
||||
return (super.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @return IRNode
|
||||
*/
|
||||
public IRNode rGetParentRNode() {
|
||||
return (parentRNode_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @param parentRNode
|
||||
*/
|
||||
public void rSetParentRNode(IRNode parentRNode) {
|
||||
this.parentRNode_ = parentRNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets child RNodes.
|
||||
*
|
||||
* @return IRNode[]
|
||||
*/
|
||||
public IRNode[] rGetRNodes() {
|
||||
List<IRNode> classNodes = new ArrayList<>();
|
||||
IRNode[] nodes = new IRNode[classNodes.size()];
|
||||
return ((IRNode[])classNodes.toArray(nodes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if a Element <code>element</code> is valid
|
||||
* for the <code>XParamListParam</code>.
|
||||
*
|
||||
* @param element
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(Element element) {
|
||||
if (!URelaxer.isTargetElement(element, "param")) {
|
||||
return (false);
|
||||
}
|
||||
RStack target = new RStack(element);
|
||||
boolean $match$ = false;
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
Element child;
|
||||
if (!URelaxer.hasAttributeHungry(target, "name")) {
|
||||
return (false);
|
||||
}
|
||||
$match$ = true;
|
||||
if (!target.isEmptyElement()) {
|
||||
return (false);
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XParamListParam</code>.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
return (isMatch(element));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XParamListParam</code>.
|
||||
* This method consumes the stack contents during matching operation.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatchHungry(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
if (isMatch(element)) {
|
||||
stack.popElement();
|
||||
return (true);
|
||||
} else {
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,627 +0,0 @@
|
||||
/*
|
||||
* The Relaxer artifact
|
||||
* Copyright (c) 2000-2004, ASAMI Tomoharu, All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.doubletype.ossa.xml;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.xml.parsers.*;
|
||||
import org.w3c.dom.*;
|
||||
import org.xml.sax.*;
|
||||
|
||||
/**
|
||||
* <b>XPoint2d</b> is generated from glyph.rng by Relaxer.
|
||||
* This class is derived from:
|
||||
*
|
||||
* <!-- for programmer
|
||||
* <element name="point2d" ns="http://doubletype.org/ns/glyph/0.0">
|
||||
* <attribute name="x">
|
||||
* <data type="double"/>
|
||||
* </attribute>
|
||||
* <attribute name="y">
|
||||
* <data type="double"/>
|
||||
* </attribute>
|
||||
* </element>-->
|
||||
* <!-- for javadoc -->
|
||||
* <pre> <element name="point2d" ns="http://doubletype.org/ns/glyph/0.0">
|
||||
* <attribute name="x">
|
||||
* <data type="double"/>
|
||||
* </attribute>
|
||||
* <attribute name="y">
|
||||
* <data type="double"/>
|
||||
* </attribute>
|
||||
* </element></pre>
|
||||
*
|
||||
* @version glyph.rng (Tue Nov 09 20:22:48 EST 2004)
|
||||
* @author Relaxer 1.1b (http://www.relaxer.org)
|
||||
*/
|
||||
public class XPoint2d implements java.io.Serializable, Cloneable, IRNode {
|
||||
private double x_;
|
||||
private double y_;
|
||||
private IRNode parentRNode_;
|
||||
|
||||
/**
|
||||
* Creates a <code>XPoint2d</code>.
|
||||
*
|
||||
*/
|
||||
public XPoint2d() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XPoint2d</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public XPoint2d(XPoint2d source) {
|
||||
setup(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XPoint2d</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public XPoint2d(RStack stack) {
|
||||
setup(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XPoint2d</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public XPoint2d(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XPoint2d</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public XPoint2d(Element element) {
|
||||
setup(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XPoint2d</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XPoint2d(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XPoint2d</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XPoint2d(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XPoint2d</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XPoint2d(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XPoint2d</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XPoint2d(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XPoint2d</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XPoint2d(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(is);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XPoint2d</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XPoint2d(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XPoint2d</code> by the XPoint2d <code>source</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public void setup(XPoint2d source) {
|
||||
int size;
|
||||
x_ = source.x_;
|
||||
y_ = source.y_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XPoint2d</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public void setup(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XPoint2d</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public void setup(Element element) {
|
||||
init(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XPoint2d</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public void setup(RStack stack) {
|
||||
init(stack.popElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param element
|
||||
*/
|
||||
private void init(Element element) {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
RStack stack = new RStack(element);
|
||||
x_ = URelaxer.getAttributePropertyAsDouble(element, "x");
|
||||
y_ = URelaxer.getAttributePropertyAsDouble(element, "y");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Object
|
||||
*/
|
||||
public Object clone() {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
return (factory.createXPoint2d((XPoint2d)this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM representation of the object.
|
||||
* Result is appended to the Node <code>parent</code>.
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
public void makeElement(Node parent) {
|
||||
Document doc;
|
||||
if (parent instanceof Document) {
|
||||
doc = (Document)parent;
|
||||
} else {
|
||||
doc = parent.getOwnerDocument();
|
||||
}
|
||||
Element element = doc.createElement("point2d");
|
||||
int size;
|
||||
URelaxer.setAttributePropertyByDouble(element, "x", this.x_);
|
||||
URelaxer.setAttributePropertyByDouble(element, "y", this.y_);
|
||||
parent.appendChild(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XPoint2d</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file.toURI().toURL());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XPoint2d</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(uri, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XPoint2d</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XPoint2d</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XPoint2d</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XPoint2d</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM document representation of the object.
|
||||
*
|
||||
* @exception ParserConfigurationException
|
||||
* @return Document
|
||||
*/
|
||||
public Document makeDocument() throws ParserConfigurationException {
|
||||
Document doc = UJAXP.makeDocument();
|
||||
makeElement(doc);
|
||||
return (doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the double property <b>x</b>.
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
public double getX() {
|
||||
return (x_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the double property <b>x</b>.
|
||||
*
|
||||
* @param x
|
||||
*/
|
||||
public void setX(double x) {
|
||||
this.x_ = x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the double property <b>y</b>.
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
public double getY() {
|
||||
return (y_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the double property <b>y</b>.
|
||||
*
|
||||
* @param y
|
||||
*/
|
||||
public void setY(double y) {
|
||||
this.y_ = y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String makeTextDocument() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
makeTextElement(buffer);
|
||||
return (new String(buffer));
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(StringBuffer buffer) {
|
||||
int size;
|
||||
buffer.append("<point2d");
|
||||
buffer.append(" x=\"");
|
||||
buffer.append(URelaxer.getString(getX()));
|
||||
buffer.append("\"");
|
||||
buffer.append(" y=\"");
|
||||
buffer.append(URelaxer.getString(getY()));
|
||||
buffer.append("\"");
|
||||
buffer.append(">");
|
||||
buffer.append("</point2d>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextElement(Writer buffer) throws IOException {
|
||||
int size;
|
||||
buffer.write("<point2d");
|
||||
buffer.write(" x=\"");
|
||||
buffer.write(URelaxer.getString(getX()));
|
||||
buffer.write("\"");
|
||||
buffer.write(" y=\"");
|
||||
buffer.write(URelaxer.getString(getY()));
|
||||
buffer.write("\"");
|
||||
buffer.write(">");
|
||||
buffer.write("</point2d>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(PrintWriter buffer) {
|
||||
int size;
|
||||
buffer.print("<point2d");
|
||||
buffer.print(" x=\"");
|
||||
buffer.print(URelaxer.getString(getX()));
|
||||
buffer.print("\"");
|
||||
buffer.print(" y=\"");
|
||||
buffer.print(URelaxer.getString(getY()));
|
||||
buffer.print("\"");
|
||||
buffer.print(">");
|
||||
buffer.print("</point2d>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(StringBuffer buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextAttribute(Writer buffer) throws IOException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(PrintWriter buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the property value as String.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getXAsString() {
|
||||
return (URelaxer.getString(getX()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the property value as String.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getYAsString() {
|
||||
return (URelaxer.getString(getY()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the property value by String.
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public void setXByString(String string) {
|
||||
setX(Double.parseDouble(string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the property value by String.
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public void setYByString(String string) {
|
||||
setY(Double.parseDouble(string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String representation of this object.
|
||||
* While this method informs as XML format representaion,
|
||||
* it's purpose is just information, not making
|
||||
* a rigid XML documentation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String toString() {
|
||||
try {
|
||||
return (makeTextDocument());
|
||||
} catch (Exception e) {
|
||||
return (super.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @return IRNode
|
||||
*/
|
||||
public IRNode rGetParentRNode() {
|
||||
return (parentRNode_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @param parentRNode
|
||||
*/
|
||||
public void rSetParentRNode(IRNode parentRNode) {
|
||||
this.parentRNode_ = parentRNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets child RNodes.
|
||||
*
|
||||
* @return IRNode[]
|
||||
*/
|
||||
public IRNode[] rGetRNodes() {
|
||||
List<IRNode> classNodes = new ArrayList<>();
|
||||
IRNode[] nodes = new IRNode[classNodes.size()];
|
||||
return ((IRNode[])classNodes.toArray(nodes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if a Element <code>element</code> is valid
|
||||
* for the <code>XPoint2d</code>.
|
||||
*
|
||||
* @param element
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(Element element) {
|
||||
if (!URelaxer.isTargetElement(element, "point2d")) {
|
||||
return (false);
|
||||
}
|
||||
RStack target = new RStack(element);
|
||||
boolean $match$ = false;
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
Element child;
|
||||
if (!URelaxer.hasAttributeHungry(target, "x")) {
|
||||
return (false);
|
||||
}
|
||||
$match$ = true;
|
||||
if (!URelaxer.hasAttributeHungry(target, "y")) {
|
||||
return (false);
|
||||
}
|
||||
$match$ = true;
|
||||
if (!target.isEmptyElement()) {
|
||||
return (false);
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XPoint2d</code>.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
return (isMatch(element));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XPoint2d</code>.
|
||||
* This method consumes the stack contents during matching operation.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatchHungry(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
if (isMatch(element)) {
|
||||
stack.popElement();
|
||||
return (true);
|
||||
} else {
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,587 +0,0 @@
|
||||
/*
|
||||
* The Relaxer artifact
|
||||
* Copyright (c) 2000-2004, ASAMI Tomoharu, All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.doubletype.ossa.xml;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.xml.parsers.*;
|
||||
import org.w3c.dom.*;
|
||||
import org.xml.sax.*;
|
||||
|
||||
/**
|
||||
* <b>XStartGlyphElement</b> is generated from glyph.rng by Relaxer.
|
||||
* This class is derived from:
|
||||
*
|
||||
* <!-- for programmer
|
||||
* <element name="glyphElement" ns="http://doubletype.org/ns/glyph/0.0">
|
||||
* <ref name="head"/>
|
||||
* <ref name="body"/>
|
||||
* </element>-->
|
||||
* <!-- for javadoc -->
|
||||
* <pre> <element name="glyphElement" ns="http://doubletype.org/ns/glyph/0.0">
|
||||
* <ref name="head"/>
|
||||
* <ref name="body"/>
|
||||
* </element></pre>
|
||||
*
|
||||
* @version glyph.rng (Tue Nov 09 20:22:48 EST 2004)
|
||||
* @author Relaxer 1.1b (http://www.relaxer.org)
|
||||
*/
|
||||
public class XStartGlyphElement implements java.io.Serializable, Cloneable, IRNode {
|
||||
private XHead head_;
|
||||
private XBody body_;
|
||||
private IRNode parentRNode_;
|
||||
|
||||
/**
|
||||
* Creates a <code>XStartGlyphElement</code>.
|
||||
*
|
||||
*/
|
||||
public XStartGlyphElement() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XStartGlyphElement</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public XStartGlyphElement(XStartGlyphElement source) {
|
||||
setup(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XStartGlyphElement</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public XStartGlyphElement(RStack stack) {
|
||||
setup(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XStartGlyphElement</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public XStartGlyphElement(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XStartGlyphElement</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public XStartGlyphElement(Element element) {
|
||||
setup(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XStartGlyphElement</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XStartGlyphElement(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XStartGlyphElement</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XStartGlyphElement(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XStartGlyphElement</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XStartGlyphElement(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XStartGlyphElement</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XStartGlyphElement(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XStartGlyphElement</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XStartGlyphElement(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(is);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>XStartGlyphElement</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public XStartGlyphElement(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XStartGlyphElement</code> by the XStartGlyphElement <code>source</code>.
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
public void setup(XStartGlyphElement source) {
|
||||
int size;
|
||||
if (source.head_ != null) {
|
||||
setHead((XHead)source.getHead().clone());
|
||||
}
|
||||
if (source.body_ != null) {
|
||||
setBody((XBody)source.getBody().clone());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XStartGlyphElement</code> by the Document <code>doc</code>.
|
||||
*
|
||||
* @param doc
|
||||
*/
|
||||
public void setup(Document doc) {
|
||||
setup(doc.getDocumentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XStartGlyphElement</code> by the Element <code>element</code>.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public void setup(Element element) {
|
||||
init(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XStartGlyphElement</code> by the Stack <code>stack</code>
|
||||
* that contains Elements.
|
||||
* This constructor is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
public void setup(RStack stack) {
|
||||
init(stack.popElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param element
|
||||
*/
|
||||
private void init(Element element) {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
RStack stack = new RStack(element);
|
||||
setHead(factory.createXHead(stack));
|
||||
setBody(factory.createXBody(stack));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Object
|
||||
*/
|
||||
public Object clone() {
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
return (factory.createXStartGlyphElement((XStartGlyphElement)this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM representation of the object.
|
||||
* Result is appended to the Node <code>parent</code>.
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
public void makeElement(Node parent) {
|
||||
Document doc;
|
||||
if (parent instanceof Document) {
|
||||
doc = (Document)parent;
|
||||
} else {
|
||||
doc = parent.getOwnerDocument();
|
||||
}
|
||||
Element element = doc.createElement("glyphElement");
|
||||
int size;
|
||||
this.head_.makeElement(element);
|
||||
this.body_.makeElement(element);
|
||||
parent.appendChild(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XStartGlyphElement</code> by the File <code>file</code>.
|
||||
*
|
||||
* @param file
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(File file) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(file.toURI().toURL());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XStartGlyphElement</code>
|
||||
* by the String representation of URI <code>uri</code>.
|
||||
*
|
||||
* @param uri
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(String uri) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(uri, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XStartGlyphElement</code> by the URL <code>url</code>.
|
||||
*
|
||||
* @param url
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(URL url) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XStartGlyphElement</code> by the InputStream <code>in</code>.
|
||||
*
|
||||
* @param in
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XStartGlyphElement</code> by the InputSource <code>is</code>.
|
||||
*
|
||||
* @param is
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(InputSource is) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <code>XStartGlyphElement</code> by the Reader <code>reader</code>.
|
||||
*
|
||||
* @param reader
|
||||
* @exception IOException
|
||||
* @exception SAXException
|
||||
* @exception ParserConfigurationException
|
||||
*/
|
||||
public void setup(Reader reader) throws IOException, SAXException, ParserConfigurationException {
|
||||
setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM document representation of the object.
|
||||
*
|
||||
* @exception ParserConfigurationException
|
||||
* @return Document
|
||||
*/
|
||||
public Document makeDocument() throws ParserConfigurationException {
|
||||
Document doc = UJAXP.makeDocument();
|
||||
makeElement(doc);
|
||||
return (doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the XHead property <b>head</b>.
|
||||
*
|
||||
* @return XHead
|
||||
*/
|
||||
public XHead getHead() {
|
||||
return (head_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XHead property <b>head</b>.
|
||||
*
|
||||
* @param head
|
||||
*/
|
||||
public void setHead(XHead head) {
|
||||
this.head_ = head;
|
||||
if (head != null) {
|
||||
head.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the XBody property <b>body</b>.
|
||||
*
|
||||
* @return XBody
|
||||
*/
|
||||
public XBody getBody() {
|
||||
return (body_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XBody property <b>body</b>.
|
||||
*
|
||||
* @param body
|
||||
*/
|
||||
public void setBody(XBody body) {
|
||||
this.body_ = body;
|
||||
if (body != null) {
|
||||
body.rSetParentRNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String makeTextDocument() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
makeTextElement(buffer);
|
||||
return (new String(buffer));
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(StringBuffer buffer) {
|
||||
int size;
|
||||
buffer.append("<glyphElement");
|
||||
buffer.append(">");
|
||||
head_.makeTextElement(buffer);
|
||||
body_.makeTextElement(buffer);
|
||||
buffer.append("</glyphElement>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextElement(Writer buffer) throws IOException {
|
||||
int size;
|
||||
buffer.write("<glyphElement");
|
||||
buffer.write(">");
|
||||
head_.makeTextElement(buffer);
|
||||
body_.makeTextElement(buffer);
|
||||
buffer.write("</glyphElement>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextElement(PrintWriter buffer) {
|
||||
int size;
|
||||
buffer.print("<glyphElement");
|
||||
buffer.print(">");
|
||||
head_.makeTextElement(buffer);
|
||||
body_.makeTextElement(buffer);
|
||||
buffer.print("</glyphElement>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(StringBuffer buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
* @exception IOException
|
||||
*/
|
||||
public void makeTextAttribute(Writer buffer) throws IOException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an XML text representation.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
public void makeTextAttribute(PrintWriter buffer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String representation of this object.
|
||||
* While this method informs as XML format representaion,
|
||||
* it's purpose is just information, not making
|
||||
* a rigid XML documentation.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String toString() {
|
||||
try {
|
||||
return (makeTextDocument());
|
||||
} catch (Exception e) {
|
||||
return (super.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @return IRNode
|
||||
*/
|
||||
public IRNode rGetParentRNode() {
|
||||
return (parentRNode_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the IRNode property <b>parentRNode</b>.
|
||||
*
|
||||
* @param parentRNode
|
||||
*/
|
||||
public void rSetParentRNode(IRNode parentRNode) {
|
||||
this.parentRNode_ = parentRNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets child RNodes.
|
||||
*
|
||||
* @return IRNode[]
|
||||
*/
|
||||
public IRNode[] rGetRNodes() {
|
||||
List<IRNode> classNodes = new ArrayList<>();
|
||||
if (head_ != null) {
|
||||
classNodes.add(head_);
|
||||
}
|
||||
if (body_ != null) {
|
||||
classNodes.add(body_);
|
||||
}
|
||||
IRNode[] nodes = new IRNode[classNodes.size()];
|
||||
return ((IRNode[])classNodes.toArray(nodes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if a Element <code>element</code> is valid
|
||||
* for the <code>XStartGlyphElement</code>.
|
||||
*
|
||||
* @param element
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(Element element) {
|
||||
if (!URelaxer.isTargetElement(element, "glyphElement")) {
|
||||
return (false);
|
||||
}
|
||||
RStack target = new RStack(element);
|
||||
boolean $match$ = false;
|
||||
IGlyphFactory factory = GlyphFactory.getFactory();
|
||||
Element child;
|
||||
if (!XHead.isMatchHungry(target)) {
|
||||
return (false);
|
||||
}
|
||||
$match$ = true;
|
||||
if (!XBody.isMatchHungry(target)) {
|
||||
return (false);
|
||||
}
|
||||
$match$ = true;
|
||||
if (!target.isEmptyElement()) {
|
||||
return (false);
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XStartGlyphElement</code>.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatch(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
return (isMatch(element));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if elements contained in a Stack <code>stack</code>
|
||||
* is valid for the <code>XStartGlyphElement</code>.
|
||||
* This method consumes the stack contents during matching operation.
|
||||
* This mehtod is supposed to be used internally
|
||||
* by the Relaxer system.
|
||||
*
|
||||
* @param stack
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMatchHungry(RStack stack) {
|
||||
Element element = stack.peekElement();
|
||||
if (element == null) {
|
||||
return (false);
|
||||
}
|
||||
if (isMatch(element)) {
|
||||
stack.popElement();
|
||||
return (true);
|
||||
} else {
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,217 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
|
||||
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
|
||||
<start>
|
||||
<element name="glyphElement"
|
||||
ns="http://doubletype.org/ns/glyph/0.0">
|
||||
<ref name="head"/>
|
||||
<ref name="body"/>
|
||||
</element>
|
||||
</start>
|
||||
|
||||
<define name="head">
|
||||
<element name="head"
|
||||
ns="http://doubletype.org/ns/glyph/0.0">
|
||||
<element name="title"><text/></element>
|
||||
<element name="unicode"><text/></element>
|
||||
|
||||
<zeroOrMore>
|
||||
<element name="unicodeRange"><text/></element>
|
||||
</zeroOrMore>
|
||||
|
||||
<zeroOrMore>
|
||||
<element name="codePage"><text/></element>
|
||||
</zeroOrMore>
|
||||
|
||||
<optional>
|
||||
<element name="ascender"><data type="double"/></element>
|
||||
</optional>
|
||||
<optional>
|
||||
<element name="descender"><data type="double"/>
|
||||
</element>
|
||||
</optional>
|
||||
<optional>
|
||||
<element name="xHeight"><data type="double"/>
|
||||
</element>
|
||||
</optional>
|
||||
|
||||
<optional>
|
||||
<element name="advanceWidth"><data type="double"/>
|
||||
</element>
|
||||
</optional>
|
||||
<optional>
|
||||
<element name="advanceHeight"><data type="double"/>
|
||||
</element>
|
||||
</optional>
|
||||
<optional>
|
||||
<element name="leftSideBearing"><data type="double"/>
|
||||
</element>
|
||||
</optional>
|
||||
<optional>
|
||||
<element name="topSideBearing"><data type="double"/>
|
||||
</element>
|
||||
</optional>
|
||||
<optional>
|
||||
<element name="bottomSideBearing"><data type="double"/>
|
||||
</element>
|
||||
</optional>
|
||||
|
||||
<optional>
|
||||
<element name="lineGap"><data type="double"/></element>
|
||||
</optional>
|
||||
<element name="author"><text/></element>
|
||||
<element name="copyright"><text/></element>
|
||||
<optional>
|
||||
<element name="version"><text/></element>
|
||||
</optional>
|
||||
|
||||
<element name="fontFamily"><text/></element>
|
||||
<element name="fontSubFamily"><text/></element>
|
||||
<element name="license"><text/></element>
|
||||
|
||||
<element name="global"><ref name="paramList"/></element>
|
||||
<element name="local"><ref name="paramList"/></element>
|
||||
</element>
|
||||
</define>
|
||||
|
||||
<define name="body">
|
||||
<element name="body"
|
||||
ns="http://doubletype.org/ns/glyph/0.0">
|
||||
<interleave>
|
||||
<zeroOrMore><ref name="glyphFile"/></zeroOrMore>
|
||||
<zeroOrMore><ref name="contour"/></zeroOrMore>
|
||||
<zeroOrMore><ref name="include"/></zeroOrMore>
|
||||
<zeroOrMore><ref name="module"/></zeroOrMore>
|
||||
</interleave>
|
||||
</element>
|
||||
</define>
|
||||
|
||||
<define name="paramList">
|
||||
<zeroOrMore>
|
||||
<element name="param"
|
||||
ns="http://doubletype.org/ns/glyph/0.0">
|
||||
<attribute name="name"/>
|
||||
<data type="double"/>
|
||||
</element>
|
||||
</zeroOrMore>
|
||||
</define>
|
||||
|
||||
<define name="contour">
|
||||
<element name="contour"
|
||||
ns="http://doubletype.org/ns/glyph/0.0">
|
||||
<optional>
|
||||
<attribute name="type"/>
|
||||
</optional>
|
||||
<oneOrMore>
|
||||
<ref name="contourPoint"/>
|
||||
</oneOrMore>
|
||||
</element>
|
||||
</define>
|
||||
|
||||
<define name="contourPoint">
|
||||
<element name="contourPoint">
|
||||
<attribute name="type">
|
||||
<choice>
|
||||
<value>on</value>
|
||||
<value>off</value>
|
||||
</choice>
|
||||
</attribute>
|
||||
<optional>
|
||||
<attribute name="rounded">
|
||||
<data type="boolean"/>
|
||||
</attribute>
|
||||
</optional>
|
||||
<ref name="point2d"/>
|
||||
<optional><ref name="controlPoint"/></optional>
|
||||
<optional><ref name="controlPoint"/></optional>
|
||||
<zeroOrMore>
|
||||
<ref name="hint"/>
|
||||
</zeroOrMore>
|
||||
</element>
|
||||
</define>
|
||||
|
||||
<define name="controlPoint">
|
||||
<element name="controlPoint"
|
||||
ns="http://doubletype.org/ns/glyph/0.0">
|
||||
<attribute name="first">
|
||||
<data type="boolean"/>
|
||||
</attribute>
|
||||
<attribute name="smooth">
|
||||
<data type="boolean"/>
|
||||
</attribute>
|
||||
<ref name="contourPoint"/>
|
||||
</element>
|
||||
</define>
|
||||
|
||||
<define name="point2d">
|
||||
<element name="point2d"
|
||||
ns="http://doubletype.org/ns/glyph/0.0">
|
||||
<attribute name="x">
|
||||
<data type="double"/>
|
||||
</attribute>
|
||||
<attribute name="y">
|
||||
<data type="double"/>
|
||||
</attribute>
|
||||
</element>
|
||||
</define>
|
||||
|
||||
<define name="hint">
|
||||
<element name="hint"
|
||||
ns="http://doubletype.org/ns/glyph/0.0">
|
||||
<attribute name="ppem">
|
||||
<data type="long"/>
|
||||
</attribute>
|
||||
<ref name="point2d"/>
|
||||
</element>
|
||||
</define>
|
||||
|
||||
<define name="glyphFile">
|
||||
<element name="glyphFile"
|
||||
ns="http://doubletype.org/ns/glyph/0.0">
|
||||
<attribute name="href"/>
|
||||
<attribute name="unicode">
|
||||
<data type="long"/>
|
||||
</attribute>
|
||||
</element>
|
||||
</define>
|
||||
|
||||
<define name="include">
|
||||
<element name="include"
|
||||
ns="http://doubletype.org/ns/glyph/0.0">
|
||||
<attribute name="href"/>
|
||||
<ref name="invoke"/>
|
||||
</element>
|
||||
</define>
|
||||
|
||||
<define name="module">
|
||||
<element name="module"
|
||||
ns="http://doubletype.org/ns/glyph/0.0">
|
||||
<attribute name="name"/>
|
||||
<ref name="invoke"/>
|
||||
<oneOrMore>
|
||||
<ref name="contourPoint"/>
|
||||
</oneOrMore>
|
||||
</element>
|
||||
</define>
|
||||
|
||||
<define name="invoke">
|
||||
<element name="invoke"
|
||||
ns="http://doubletype.org/ns/glyph/0.0">
|
||||
<element name="pos">
|
||||
<ref name="point2d"/>
|
||||
</element>
|
||||
<zeroOrMore>
|
||||
<element name="arg">
|
||||
<attribute name="name"/>
|
||||
<data type="double"/>
|
||||
</element>
|
||||
</zeroOrMore>
|
||||
<zeroOrMore>
|
||||
<element name="varg">
|
||||
<attribute name="name"/>
|
||||
<attribute name="src"/>
|
||||
</element>
|
||||
</zeroOrMore>
|
||||
</element>
|
||||
</define>
|
||||
</grammar>
|
||||
Reference in New Issue
Block a user