diff options
Diffstat (limited to 'framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional')
19 files changed, 0 insertions, 2296 deletions
diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/AbstractScriptComponent.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/AbstractScriptComponent.java deleted file mode 100644 index df5a3cec..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/AbstractScriptComponent.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.types.optional; - -import java.io.File; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.ProjectComponent; -import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.types.Reference; -import org.apache.tools.ant.util.ScriptRunnerBase; -import org.apache.tools.ant.util.ScriptRunnerHelper; - -/** - * This is a {@link ProjectComponent} that has script support built in - * Use it as a foundation for scriptable things. - */ -public abstract class AbstractScriptComponent extends ProjectComponent { - /** - * script runner helper - */ - private ScriptRunnerHelper helper = new ScriptRunnerHelper(); - - /** - * script runner. - */ - private ScriptRunnerBase runner = null; - - /** - * Set the project. - * @param project the owner of this component. - */ - public void setProject(Project project) { - super.setProject(project); - helper.setProjectComponent(this); - } - - /** - * Get our script runner - * @return the runner - */ - public ScriptRunnerBase getRunner() { - initScriptRunner(); - return runner; - } - - /** - * Load the script from an external file ; optional. - * - * @param file the file containing the script source. - */ - public void setSrc(File file) { - helper.setSrc(file); - } - - /** - * The script text. - * - * @param text a component of the script text to be added. - */ - public void addText(String text) { - helper.addText(text); - } - - /** - * Defines the manager. - * - * @param manager the scripting manager. - */ - public void setManager(String manager) { - helper.setManager(manager); - } - - /** - * Defines the language (required). - * - * @param language the scripting language name for the script. - */ - public void setLanguage(String language) { - helper.setLanguage(language); - } - - /** - * Initialize the script runner. Calls this before running the system - */ - protected void initScriptRunner() { - if (runner != null) { - return; - } - helper.setProjectComponent(this); - runner = helper.getScriptRunner(); - } - /** - * Set the classpath to be used when searching for classes and resources. - * - * @param classpath an Ant Path object containing the search path. - */ - public void setClasspath(Path classpath) { - helper.setClasspath(classpath); - } - - /** - * Classpath to be used when searching for classes and resources. - * - * @return an empty Path instance to be configured by Ant. - */ - public Path createClasspath() { - return helper.createClasspath(); - } - - /** - * Set the classpath by reference. - * - * @param r a Reference to a Path instance to be used as the classpath - * value. - */ - public void setClasspathRef(Reference r) { - helper.setClasspathRef(r); - } - - /** - * Run a script - * @param execName name of the script - */ - protected void executeScript(String execName) { - getRunner().executeScript(execName); - } - - /** - * Set the setbeans attribute. - * If this is true, <script> will create variables in the - * script instance for all - * properties, targets and references of the current project. - * It this is false, only the project and self variables will - * be set. - * The default is true. - * @param setBeans the value to set. - * @since Ant 1.8.0 - */ - public void setSetBeans(boolean setBeans) { - helper.setSetBeans(setBeans); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/ScriptCondition.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/ScriptCondition.java deleted file mode 100644 index fac02bfa..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/ScriptCondition.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.types.optional; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.taskdefs.condition.Condition; - -/** - * A condition that lets you include script. - * The condition component sets a bean "self", whose attribute "value" - * must be set to true for the condition to succeed, false to fail. - * The default is 'false' - */ -public class ScriptCondition extends AbstractScriptComponent implements Condition { - - /** - * result field - */ - private boolean value = false; - - /** - * Is this condition true? - * - * @return true if the condition is true - * - * @throws org.apache.tools.ant.BuildException - * if an error occurs - */ - public boolean eval() throws BuildException { - initScriptRunner(); - executeScript("ant_condition"); - return getValue(); - } - - /** - * get the current value of the condition - * @return true if the condition - */ - public boolean getValue() { - return value; - } - - /** - * set the value of the condition. - * This is used by the script to pass the return value. - * It can be used by an attribute, in which case it sets the default - * value - * @param value the value to set the condition to - */ - public void setValue(boolean value) { - this.value = value; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/ScriptFilter.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/ScriptFilter.java deleted file mode 100644 index 3f6ec88f..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/ScriptFilter.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types.optional; - -import java.io.File; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.filters.TokenFilter; -import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.types.Reference; -import org.apache.tools.ant.util.ScriptRunnerBase; -import org.apache.tools.ant.util.ScriptRunnerHelper; - -/** - * Most of this is CAP (Cut And Paste) from the Script task - * ScriptFilter class, implements TokenFilter.Filter - * for scripts to use. - * This provides the same beans as the Script Task - * to a script. - * The script is meant to use get self.token and - * set self.token in the reply. - * - * @since Ant 1.6 - */ -public class ScriptFilter extends TokenFilter.ChainableReaderFilter { - /** script runner helper */ - private ScriptRunnerHelper helper = new ScriptRunnerHelper(); - - /** script runner. */ - private ScriptRunnerBase runner = null; - - /** the token used by the script */ - private String token; - - /** - * Set the project. - * @param project the owner of this component. - */ - public void setProject(Project project) { - super.setProject(project); - helper.setProjectComponent(this); - } - - /** - * Defines the language (required). - * - * @param language the scripting language name for the script. - */ - public void setLanguage(String language) { - helper.setLanguage(language); - } - - /** - * Initialize. - * - * @exception BuildException if someting goes wrong - */ - private void init() throws BuildException { - if (runner != null) { - return; - } - runner = helper.getScriptRunner(); - } - - /** - * The current token - * - * @param token the string filtered by the script - */ - public void setToken(String token) { - this.token = token; - } - - /** - * The current token - * - * @return the string filtered by the script - */ - public String getToken() { - return token; - } - - /** - * Called filter the token. - * This sets the token in this object, calls - * the script and returns the token. - * - * @param token the token to be filtered - * @return the filtered token - */ - public String filter(String token) { - init(); - setToken(token); - runner.executeScript("ant_filter"); - return getToken(); - } - - /** - * Load the script from an external file ; optional. - * - * @param file the file containing the script source. - */ - public void setSrc(File file) { - helper.setSrc(file); - } - - /** - * The script text. - * - * @param text a component of the script text to be added. - */ - public void addText(String text) { - helper.addText(text); - } - - /** - * Defines the manager. - * - * @param manager the scripting manager. - */ - public void setManager(String manager) { - helper.setManager(manager); - } - /** - * Set the classpath to be used when searching for classes and resources. - * - * @param classpath an Ant Path object containing the search path. - */ - public void setClasspath(Path classpath) { - helper.setClasspath(classpath); - } - - /** - * Classpath to be used when searching for classes and resources. - * - * @return an empty Path instance to be configured by Ant. - */ - public Path createClasspath() { - return helper.createClasspath(); - } - - /** - * Set the classpath by reference. - * - * @param r a Reference to a Path instance to be used as the classpath - * value. - */ - public void setClasspathRef(Reference r) { - helper.setClasspathRef(r); - } - - /** - * Set the setbeans attribute. - * If this is true, <script> will create variables in the - * script instance for all - * properties, targets and references of the current project. - * It this is false, only the project and self variables will - * be set. - * The default is true. - * @param setBeans the value to set. - * @since Ant 1.8.0 - */ - public void setSetBeans(boolean setBeans) { - helper.setSetBeans(setBeans); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/ScriptMapper.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/ScriptMapper.java deleted file mode 100644 index 38dab0bb..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/ScriptMapper.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.types.optional; - -import java.util.ArrayList; - -import org.apache.tools.ant.util.FileNameMapper; - -/** - * Script support at map time. - * @since Ant1.7 - */ -public class ScriptMapper extends AbstractScriptComponent implements FileNameMapper { - - private ArrayList<String> files; - - - /** - * Sets the from part of the transformation rule. - * - * @param from a string. - */ - public void setFrom(String from) { - - } - - /** - * Sets the to part of the transformation rule. - * - * @param to a string. - */ - public void setTo(String to) { - - } - - /** - * Reset the list of files - */ - public void clear() { - files = new ArrayList<String>(1); - } - - /** - * Add a mapped name - * @param mapping the value to use. - */ - public void addMappedName(String mapping) { - files.add(mapping); - } - - /** - * Returns an array containing the target filename(s) for the given source - * file. - * <p/> - * <p>if the given rule doesn't apply to the source file, implementation - * must return null. SourceFileScanner will then omit the source file in - * question.</p> - * - * @param sourceFileName the name of the source file relative to some given - * basedirectory. - * @return an array of strings if the rule applies to the source file, or - * null if it does not. - */ - - public String[] mapFileName(String sourceFileName) { - initScriptRunner(); - getRunner().addBean("source", sourceFileName); - clear(); - executeScript("ant_mapper"); - if (files.size() == 0) { - return null; - } else { - return files.toArray(new String[files.size()]); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/ScriptSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/ScriptSelector.java deleted file mode 100644 index ca28f69f..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/ScriptSelector.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.types.optional; - -import java.io.File; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.types.Reference; -import org.apache.tools.ant.types.selectors.BaseSelector; -import org.apache.tools.ant.util.ScriptRunnerBase; -import org.apache.tools.ant.util.ScriptRunnerHelper; - -/** - * Selector that lets you run a script with selection logic inline - * @since Ant1.7 - */ -public class ScriptSelector extends BaseSelector { - - /** - * script runner helper - */ - private ScriptRunnerHelper helper = new ScriptRunnerHelper(); - - /** - * script runner - */ - private ScriptRunnerBase runner; - - /** - * fields updated for every selection - */ - private File basedir; - private String filename; - private File file; - - /** - * selected flag - */ - private boolean selected; - - /** - * Set the project. - * @param project the owner of this component. - */ - public void setProject(Project project) { - super.setProject(project); - helper.setProjectComponent(this); - } - - /** - * Defines the manager. - * - * @param manager the scripting manager. - */ - public void setManager(String manager) { - helper.setManager(manager); - } - - /** - * Defines the language (required). - * - * @param language the scripting language name for the script. - */ - public void setLanguage(String language) { - helper.setLanguage(language); - } - - /** - * Initialize on demand. - * - * @throws org.apache.tools.ant.BuildException - * if someting goes wrong - */ - private void init() throws BuildException { - if (runner != null) { - return; - } - runner = helper.getScriptRunner(); - } - - /** - * Load the script from an external file ; optional. - * - * @param file the file containing the script source. - */ - public void setSrc(File file) { - helper.setSrc(file); - } - - /** - * The script text. - * - * @param text a component of the script text to be added. - */ - public void addText(String text) { - helper.addText(text); - } - - /** - * Set the classpath to be used when searching for classes and resources. - * - * @param classpath an Ant Path object containing the search path. - */ - public void setClasspath(Path classpath) { - helper.setClasspath(classpath); - } - - /** - * Classpath to be used when searching for classes and resources. - * - * @return an empty Path instance to be configured by Ant. - */ - public Path createClasspath() { - return helper.createClasspath(); - } - - /** - * Set the classpath by reference. - * - * @param r a Reference to a Path instance to be used as the classpath - * value. - */ - public void setClasspathRef(Reference r) { - helper.setClasspathRef(r); - } - - /** - * Set the setbeans attribute. - * If this is true, <script> will create variables in the - * script instance for all - * properties, targets and references of the current project. - * It this is false, only the project and self variables will - * be set. - * The default is true. - * @param setBeans the value to set. - */ - public void setSetBeans(boolean setBeans) { - helper.setSetBeans(setBeans); - } - - /** - * Method that each selector will implement to create their selection - * behaviour. If there is a problem with the setup of a selector, it can - * throw a BuildException to indicate the problem. - * - * @param basedir A java.io.File object for the base directory - * @param filename The name of the file to check - * @param file A File object for this filename - * - * @return whether the file should be selected or not - */ - public boolean isSelected(File basedir, String filename, File file) { - init(); - setSelected(true); - this.file = file; - this.basedir = basedir; - this.filename = filename; - runner.addBean("basedir", basedir); - runner.addBean("filename", filename); - runner.addBean("file", file); - runner.executeScript("ant_selector"); - return isSelected(); - } - - /** - * get the base directory - * @return the base directory - */ - public File getBasedir() { - return basedir; - } - - /** - * get the filename of the file - * @return the filename of the file that is currently been tested - */ - public String getFilename() { - return filename; - } - - /** - * get the file that is currently to be tested - * @return the file that is currently been tested - */ - public File getFile() { - return file; - } - - /** - * get state of selected flag - * @return the selected flag - */ - public boolean isSelected() { - return selected; - } - - /** - * set the selected state - * Intended for script use, not as an Ant attribute - * @param selected the selected state - */ - public void setSelected(boolean selected) { - this.selected = selected; - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/depend/ClassfileSet.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/depend/ClassfileSet.java deleted file mode 100644 index f2fe69b1..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/depend/ClassfileSet.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.types.optional.depend; - -import java.util.ArrayList; -import java.util.List; -import java.util.Stack; -import java.util.Vector; - -import org.apache.tools.ant.DirectoryScanner; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.FileSet; -import org.apache.tools.ant.util.StringUtils; - -/** - * A ClassfileSet is a FileSet that enlists all classes that depend on a - * certain set of root classes. - * - * ClassfileSet extends FileSet, its inherited properties - * defining the domain searched for dependent classes. - * - */ -public class ClassfileSet extends FileSet { - /** - * The list of root classes for this class file set. These are the - * classes which must be included in the fileset and which are the - * starting point for the dependency search. - */ - private List<String> rootClasses = new ArrayList<String>(); - - /** - * The list of filesets which contain root classes. - */ - private List<FileSet> rootFileSets = new ArrayList<FileSet>(); - - /** - * Inner class used to contain info about root classes. - */ - public static class ClassRoot { - /** The name of the root class */ - private String rootClass; - - /** - * Set the root class name. - * - * @param name the name of the root class. - */ - public void setClassname(String name) { - this.rootClass = name; - } - - /** - * Get the name of the root class. - * - * @return the name of the root class. - */ - public String getClassname() { - return rootClass; - } - } - - /** - * Default constructor. - */ - public ClassfileSet() { - } - - /** - * Add a fileset to which contains a collection of root classes used to - * drive the search from classes. - * - * @param rootFileSet a root file set to be used to search for dependent - * classes. - */ - public void addRootFileset(FileSet rootFileSet) { - rootFileSets.add(rootFileSet); - setChecked(false); - } - - /** - * Create a ClassfileSet from another ClassfileSet. - * - * @param s the other classfileset. - */ - protected ClassfileSet(ClassfileSet s) { - super(s); - rootClasses.addAll(s.rootClasses); - } - - /** - * Set the root class attribute. - * - * @param rootClass the name of the root class. - */ - public void setRootClass(String rootClass) { - rootClasses.add(rootClass); - } - - /** - * Return the DirectoryScanner associated with this FileSet. - * - * @param p the project used to resolve dirs, etc. - * - * @return a dependency scanner. - */ - public DirectoryScanner getDirectoryScanner(Project p) { - if (isReference()) { - return getRef(p).getDirectoryScanner(p); - } - dieOnCircularReference(p); - DirectoryScanner parentScanner = super.getDirectoryScanner(p); - DependScanner scanner = new DependScanner(parentScanner); - final Vector<String> allRootClasses = new Vector<String>(rootClasses); - for (FileSet additionalRootSet : rootFileSets) { - DirectoryScanner additionalScanner - = additionalRootSet.getDirectoryScanner(p); - String[] files = additionalScanner.getIncludedFiles(); - for (int i = 0; i < files.length; ++i) { - if (files[i].endsWith(".class")) { - String classFilePath = StringUtils.removeSuffix(files[i], ".class"); - String className - = classFilePath.replace('/', '.').replace('\\', '.'); - allRootClasses.addElement(className); - } - } - scanner.addBasedir(additionalRootSet.getDir(p)); - } - scanner.setBasedir(getDir(p)); - scanner.setRootClasses(allRootClasses); - scanner.scan(); - return scanner; - } - - /** - * Add a nested root class definition to this class file set. - * - * @param root the configured class root. - */ - public void addConfiguredRoot(ClassRoot root) { - rootClasses.add(root.getClassname()); - } - - /** - * Clone this data type. - * - * @return a clone of the class file set. - */ - public Object clone() { - return new ClassfileSet(isReference() - ? (ClassfileSet) (getRef(getProject())) : this); - } - - protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) { - if (isChecked()) { - return; - } - - // takes care of nested selectors - super.dieOnCircularReference(stk, p); - - if (!isReference()) { - for (FileSet additionalRootSet : rootFileSets) { - pushAndInvokeCircularReferenceCheck(additionalRootSet, stk, p); - } - setChecked(true); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/depend/DependScanner.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/depend/DependScanner.java deleted file mode 100644 index bb3cf54b..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/depend/DependScanner.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.types.optional.depend; - -import java.io.File; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Vector; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.DirectoryScanner; -import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.util.depend.DependencyAnalyzer; - - -/** - * DirectoryScanner for finding class dependencies. - */ -public class DependScanner extends DirectoryScanner { - /** - * The name of the analyzer to use by default. - */ - public static final String DEFAULT_ANALYZER_CLASS - = "org.apache.tools.ant.util.depend.bcel.FullAnalyzer"; - - /** - * The root classes to drive the search for dependent classes. - */ - private Vector<String> rootClasses; - - /** - * The names of the classes to include in the fileset. - */ - private Vector<String> included; - - private Vector<File> additionalBaseDirs = new Vector<File>(); - - /** - * The parent scanner which gives the basic set of files. Only files which - * are in this set and which can be reached from a root class will end - * up being included in the result set. - */ - private DirectoryScanner parentScanner; - - /** - * Create a DependScanner, using the given scanner to provide the basic - * set of files from which class files come. - * - * @param parentScanner the DirectoryScanner which returns the files from - * which class files must come. - */ - public DependScanner(DirectoryScanner parentScanner) { - this.parentScanner = parentScanner; - } - - /** - * Sets the root classes to be used to drive the scan. - * - * @param rootClasses the rootClasses to be used for this scan. - */ - public synchronized void setRootClasses(Vector<String> rootClasses) { - this.rootClasses = rootClasses; - } - - /** - * Get the names of the class files on which baseClass depends. - * - * @return the names of the files. - */ - public String[] getIncludedFiles() { - String[] files = new String[getIncludedFilesCount()]; - for (int i = 0; i < files.length; i++) { - files[i] = (String) included.elementAt(i); - } - return files; - } - - /** {@inheritDoc}. */ - public synchronized int getIncludedFilesCount() { - if (included == null) { - throw new IllegalStateException(); - } - return included.size(); - } - - /** - * Scans the base directory for files on which baseClass depends. - * - * @exception IllegalStateException when basedir was set incorrectly. - */ - public synchronized void scan() throws IllegalStateException { - included = new Vector<String>(); - String analyzerClassName = DEFAULT_ANALYZER_CLASS; - DependencyAnalyzer analyzer = null; - try { - Class<? extends DependencyAnalyzer> analyzerClass = Class.forName(analyzerClassName) - .asSubclass(DependencyAnalyzer.class); - analyzer = analyzerClass.newInstance(); - } catch (Exception e) { - throw new BuildException("Unable to load dependency analyzer: " - + analyzerClassName, e); - } - analyzer.addClassPath(new Path(null, basedir.getPath())); - for (Enumeration<File> e = additionalBaseDirs.elements(); e.hasMoreElements();) { - File additionalBaseDir = e.nextElement(); - analyzer.addClassPath(new Path(null, additionalBaseDir.getPath())); - } - - for (Enumeration<String> e = rootClasses.elements(); e.hasMoreElements();) { - String rootClass = e.nextElement(); - analyzer.addRootClass(rootClass); - } - Enumeration<String> e = analyzer.getClassDependencies(); - - String[] parentFiles = parentScanner.getIncludedFiles(); - Hashtable<String, String> parentSet = new Hashtable<String, String>(); - for (int i = 0; i < parentFiles.length; ++i) { - parentSet.put(parentFiles[i], parentFiles[i]); - } - while (e.hasMoreElements()) { - String classname = (String) e.nextElement(); - String filename = classname.replace('.', File.separatorChar); - filename = filename + ".class"; - File depFile = new File(basedir, filename); - if (depFile.exists() && parentSet.containsKey(filename)) { - // This is included - included.addElement(filename); - } - } - } - - /** - * @see DirectoryScanner#addDefaultExcludes - */ - public void addDefaultExcludes() { - } - - /** - * @see DirectoryScanner#getExcludedDirectories - */ - /** {@inheritDoc}. */ - public String[] getExcludedDirectories() { - return null; - } - - /** - * @see DirectoryScanner#getExcludedFiles - */ - /** {@inheritDoc}. */ - public String[] getExcludedFiles() { - return null; - } - - /** - * @see DirectoryScanner#getIncludedDirectories - */ - /** {@inheritDoc}. */ - public String[] getIncludedDirectories() { - return new String[0]; - } - - /** - * @see DirectoryScanner#getIncludedDirsCount - */ - /** {@inheritDoc}. */ - public int getIncludedDirsCount() { - return 0; - } - - /** - * @see DirectoryScanner#getNotIncludedDirectories - */ - /** {@inheritDoc}. */ - public String[] getNotIncludedDirectories() { - return null; - } - - /** - * @see DirectoryScanner#getNotIncludedFiles - */ - /** {@inheritDoc}. */ - public String[] getNotIncludedFiles() { - return null; - } - - /** - * @see DirectoryScanner#setExcludes - */ - /** {@inheritDoc}. */ - public void setExcludes(String[] excludes) { - } - - /** - * @see DirectoryScanner#setIncludes - */ - /** {@inheritDoc}. */ - public void setIncludes(String[] includes) { - } - - /** - * @see DirectoryScanner#setCaseSensitive - */ - /** {@inheritDoc}. */ - public void setCaseSensitive(boolean isCaseSensitive) { - } - - public void addBasedir(File baseDir) { - additionalBaseDirs.addElement(baseDir); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Arc.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Arc.java deleted file mode 100644 index 3d8b29b2..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Arc.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.types.optional.image; - -import java.awt.BasicStroke; -import java.awt.Graphics2D; -import java.awt.geom.Arc2D; -import java.awt.image.BufferedImage; - -import javax.media.jai.PlanarImage; - -/** - * Draw an arc. - */ -public class Arc extends BasicShape implements DrawOperation { - // CheckStyle:VisibilityModifier OFF - bc - protected int width = 0; - protected int height = 0; - protected int start = 0; - protected int stop = 0; - protected int type = Arc2D.OPEN; - // CheckStyle:VisibilityModifier ON - - /** - * Set the width. - * @param width the width of the arc. - */ - public void setWidth(int width) { - this.width = width; - } - - /** - * Set the height. - * @param height the height of the arc. - */ - public void setHeight(int height) { - this.height = height; - } - - /** - * Set the start of the arc. - * @param start the start of the arc. - */ - public void setStart(int start) { - this.start = start; - } - - /** - * Set the stop of the arc. - * @param stop the stop of the arc. - */ - public void setStop(int stop) { - this.stop = stop; - } - - /** - * Set the type of arc. - * @param strType the type to use - open, pie or chord. - * @todo refactor using an EnumeratedAttribute - */ - public void setType(String strType) { - if (strType.equalsIgnoreCase("open")) { - type = Arc2D.OPEN; - } else if (strType.equalsIgnoreCase("pie")) { - type = Arc2D.PIE; - } else if (strType.equalsIgnoreCase("chord")) { - type = Arc2D.CHORD; - } - } - - /** {@inheritDoc}. */ - public PlanarImage executeDrawOperation() { - BufferedImage bi = new BufferedImage(width + (stroke_width * 2), - height + (stroke_width * 2), BufferedImage.TYPE_4BYTE_ABGR_PRE); - - Graphics2D graphics = (Graphics2D) bi.getGraphics(); - - if (!stroke.equals("transparent")) { - BasicStroke bStroke = new BasicStroke(stroke_width); - graphics.setColor(ColorMapper.getColorByName(stroke)); - graphics.setStroke(bStroke); - graphics.draw(new Arc2D.Double(stroke_width, stroke_width, width, - height, start, stop, type)); - } - - if (!fill.equals("transparent")) { - graphics.setColor(ColorMapper.getColorByName(fill)); - graphics.fill(new Arc2D.Double(stroke_width, stroke_width, - width, height, start, stop, type)); - } - - - final int size = instructions.size(); - for (int i = 0; i < size; i++) { - ImageOperation instr = ((ImageOperation) instructions.elementAt(i)); - if (instr instanceof DrawOperation) { - PlanarImage img = ((DrawOperation) instr).executeDrawOperation(); - graphics.drawImage(img.getAsBufferedImage(), null, 0, 0); - } else if (instr instanceof TransformOperation) { - graphics = (Graphics2D) bi.getGraphics(); - PlanarImage image = ((TransformOperation) instr) - .executeTransformOperation(PlanarImage.wrapRenderedImage(bi)); - bi = image.getAsBufferedImage(); - } - } - return PlanarImage.wrapRenderedImage(bi); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/BasicShape.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/BasicShape.java deleted file mode 100644 index ee2113a7..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/BasicShape.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.types.optional.image; - - -/** Draw a basic shape */ -public abstract class BasicShape extends ImageOperation implements DrawOperation { - // CheckStyle:VisibilityModifier OFF - bc - // CheckStyle:MemberNameCheck OFF - bc - protected int stroke_width = 0; - // CheckStyle:MemberNameCheck ON - protected String fill = "transparent"; - protected String stroke = "black"; - // CheckStyle:VisibilityModifier ON - - - /** - * Set the fill attribute. - * @param col the color value to use. - */ - public void setFill(String col) { - fill = col; - } - - /** - * Set the stroke attribute. - * @param col the color value to use. - */ - public void setStroke(String col) { - stroke = col; - } - - /** - * Set the stroke width attribute. - * @param width the value to use. - */ - public void setStrokewidth(int width) { - stroke_width = width; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/ColorMapper.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/ColorMapper.java deleted file mode 100644 index 88e2871a..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/ColorMapper.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.types.optional.image; - -import java.awt.Color; - -/** - * - * @see org.apache.tools.ant.taskdefs.optional.image.Image - */ -public final class ColorMapper { - /** private constructor for Utility class */ - private ColorMapper() { - } - - /** black string */ - public static final String COLOR_BLACK = "black"; - /** blue string */ - public static final String COLOR_BLUE = "blue"; - /** cyan string */ - public static final String COLOR_CYAN = "cyan"; - /** black string */ - public static final String COLOR_DARKGRAY = "darkgray"; - /** gray string */ - public static final String COLOR_GRAY = "gray"; - /** lightgray string */ - public static final String COLOR_LIGHTGRAY = "lightgray"; - // Gotta at least put in the proper spelling :-P - /** darkgrey string */ - public static final String COLOR_DARKGREY = "darkgrey"; - /** grey string */ - public static final String COLOR_GREY = "grey"; - /** lightgrey string */ - public static final String COLOR_LIGHTGREY = "lightgrey"; - /** green string */ - public static final String COLOR_GREEN = "green"; - /** magenta string */ - public static final String COLOR_MAGENTA = "magenta"; - /** orange string */ - public static final String COLOR_ORANGE = "orange"; - /** pink string */ - public static final String COLOR_PINK = "pink"; - /** reg string */ - public static final String COLOR_RED = "red"; - /** white string */ - public static final String COLOR_WHITE = "white"; - /** yellow string */ - public static final String COLOR_YELLOW = "yellow"; - - /** - * Convert a color name to a color value. - * @param colorName a string repr of the color. - * @return the color value. - * @todo refactor to use an EnumeratedAttribute (maybe?) - */ - public static Color getColorByName(String colorName) { - if (colorName.equalsIgnoreCase(COLOR_BLACK)) { - return Color.black; - } else if (colorName.equalsIgnoreCase(COLOR_BLUE)) { - return Color.blue; - } else if (colorName.equalsIgnoreCase(COLOR_CYAN)) { - return Color.cyan; - } else if (colorName.equalsIgnoreCase(COLOR_DARKGRAY) || colorName.equalsIgnoreCase(COLOR_DARKGREY)) { - return Color.darkGray; - } else if (colorName.equalsIgnoreCase(COLOR_GRAY) || colorName.equalsIgnoreCase(COLOR_GREY)) { - return Color.gray; - } else if (colorName.equalsIgnoreCase(COLOR_LIGHTGRAY) || colorName.equalsIgnoreCase(COLOR_LIGHTGREY)) { - return Color.lightGray; - } else if (colorName.equalsIgnoreCase(COLOR_GREEN)) { - return Color.green; - } else if (colorName.equalsIgnoreCase(COLOR_MAGENTA)) { - return Color.magenta; - } else if (colorName.equalsIgnoreCase(COLOR_ORANGE)) { - return Color.orange; - } else if (colorName.equalsIgnoreCase(COLOR_PINK)) { - return Color.pink; - } else if (colorName.equalsIgnoreCase(COLOR_RED)) { - return Color.red; - } else if (colorName.equalsIgnoreCase(COLOR_WHITE)) { - return Color.white; - } else if (colorName.equalsIgnoreCase(COLOR_YELLOW)) { - return Color.yellow; - } - return Color.black; - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Draw.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Draw.java deleted file mode 100644 index 2f097d5d..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Draw.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.types.optional.image; - -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; - -import javax.media.jai.PlanarImage; - -/** - * - * @see org.apache.tools.ant.taskdefs.optional.image.Image - */ -public class Draw extends TransformOperation { - // CheckStyle:VisibilityModifier OFF - bc - protected int xloc = 0; - protected int yloc = 0; - // CheckStyle:VisibilityModifier ON - - /** - * Set the X location. - * @param x the value to use. - */ - public void setXloc(int x) { - xloc = x; - } - - /** - * Set the Y location. - * @param y the value to use. - */ - public void setYloc(int y) { - yloc = y; - } - - /** {@inheritDoc}. */ - public void addRectangle(Rectangle rect) { - instructions.add(rect); - } - - /** {@inheritDoc}. */ - public void addText(Text text) { - instructions.add(text); - } - - /** - * Add an ellipse. - * @param elip the ellipse to add. - */ - public void addEllipse(Ellipse elip) { - instructions.add(elip); - } - - /** - * Add an arc. - * @param arc the arc to add. - */ - public void addArc(Arc arc) { - instructions.add(arc); - } - - /** {@inheritDoc}. */ - public PlanarImage executeTransformOperation(PlanarImage image) { - BufferedImage bi = image.getAsBufferedImage(); - Graphics2D graphics = (Graphics2D) bi.getGraphics(); - - final int size = instructions.size(); - for (int i = 0; i < size; i++) { - ImageOperation instr = ((ImageOperation) instructions.elementAt(i)); - if (instr instanceof DrawOperation) { - PlanarImage op = ((DrawOperation) instr).executeDrawOperation(); - log("\tDrawing to x=" + xloc + " y=" + yloc); - graphics.drawImage(op.getAsBufferedImage(), null, xloc, yloc); - } else if (instr instanceof TransformOperation) { - PlanarImage op - = ((TransformOperation) instr).executeTransformOperation(null); - BufferedImage child = op.getAsBufferedImage(); - log("\tDrawing to x=" + xloc + " y=" + yloc); - graphics.drawImage(child, null, xloc, yloc); - PlanarImage.wrapRenderedImage(bi); - } - } - image = PlanarImage.wrapRenderedImage(bi); - - return image; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/DrawOperation.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/DrawOperation.java deleted file mode 100644 index 4f6410ca..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/DrawOperation.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.types.optional.image; - -import javax.media.jai.PlanarImage; - - -/** - * Interface which represents an Operation which is "drawable", such - * as a Rectangle, Circle or Text. The Operation is responsible for - * creating its own image buffer and drawing itself into it, then - * wrapping and returning it as a PlanarImage. This allows multible - * "drawable" objects to be nested. - * - * @see org.apache.tools.ant.taskdefs.optional.image.Image - */ -public interface DrawOperation { - /** - * Abstract method which is intended to create an image buffer - * and return it so it can be drawn into another object. Use - * an Alpha channel for a "transparent" background. - * @return a planar image - */ - PlanarImage executeDrawOperation(); -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Ellipse.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Ellipse.java deleted file mode 100644 index 9924d906..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Ellipse.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.types.optional.image; - -import java.awt.BasicStroke; -import java.awt.Graphics2D; -import java.awt.geom.Ellipse2D; -import java.awt.image.BufferedImage; - -import javax.media.jai.PlanarImage; - -/** - * Draw an ellipse. - * @see org.apache.tools.ant.taskdefs.optional.image.Image - */ -public class Ellipse extends BasicShape implements DrawOperation { - // CheckStyle:VisibilityModifier OFF - bc - protected int width = 0; - protected int height = 0; - // CheckStyle:VisibilityModifier ON - - /** - * Set the width. - * @param width the width of the elipse. - */ - public void setWidth(int width) { - this.width = width; - } - - /** - * Set the height. - * @param height the height of the ellipse. - */ - public void setHeight(int height) { - this.height = height; - } - - /** {@inheritDoc}. */ - public PlanarImage executeDrawOperation() { - BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR_PRE); - - Graphics2D graphics = (Graphics2D) bi.getGraphics(); - - if (!stroke.equals("transparent")) { - BasicStroke bStroke = new BasicStroke(stroke_width); - graphics.setColor(ColorMapper.getColorByName(stroke)); - graphics.setStroke(bStroke); - graphics.draw(new Ellipse2D.Double(0, 0, width, height)); - } - - if (!fill.equals("transparent")) { - graphics.setColor(ColorMapper.getColorByName(fill)); - graphics.fill(new Ellipse2D.Double(0, 0, width, height)); - } - - - final int size = instructions.size(); - for (int i = 0; i < size; i++) { - ImageOperation instr = ((ImageOperation) instructions.elementAt(i)); - if (instr instanceof DrawOperation) { - PlanarImage img = ((DrawOperation) instr).executeDrawOperation(); - graphics.drawImage(img.getAsBufferedImage(), null, 0, 0); - } else if (instr instanceof TransformOperation) { - graphics = (Graphics2D) bi.getGraphics(); - PlanarImage image = ((TransformOperation) instr) - .executeTransformOperation(PlanarImage.wrapRenderedImage(bi)); - bi = image.getAsBufferedImage(); - } - } - return PlanarImage.wrapRenderedImage(bi); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/ImageOperation.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/ImageOperation.java deleted file mode 100644 index d72fe049..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/ImageOperation.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.types.optional.image; - -import java.util.Vector; - -import org.apache.tools.ant.types.DataType; - -/** - * - * @see org.apache.tools.ant.taskdefs.optional.image.Image - */ -public abstract class ImageOperation extends DataType { - // CheckStyle:VisibilityModifier OFF - bc - protected Vector<ImageOperation> instructions = new Vector<ImageOperation>(); - // CheckStyle:VisibilityModifier ON - - /** - * Add a rotate to the operation. - * @param instr the rotate to add. - */ - public void addRotate(Rotate instr) { - instructions.add(instr); - } - - /** - * Add a draw to the operation. - * @param instr the draw to add. - */ - public void addDraw(Draw instr) { - instructions.add(instr); - } - - /** - * Add a rectangle to the operation. - * @param instr the rectangle to add. - */ - public void addRectangle(Rectangle instr) { - instructions.add(instr); - } - - /** - * Add text to the operation. - * @param instr the text to add. - */ - public void addText(Text instr) { - instructions.add(instr); - } - - /** - * Add a scale to the operation. - * @param instr the scale to add. - */ - public void addScale(Scale instr) { - instructions.add(instr); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Rectangle.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Rectangle.java deleted file mode 100644 index e2d5bb1b..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Rectangle.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.types.optional.image; - -import java.awt.BasicStroke; -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; - -import javax.media.jai.PlanarImage; - -/** - * - * @see org.apache.tools.ant.taskdefs.optional.image.Image - */ -public class Rectangle extends BasicShape implements DrawOperation { - // CheckStyle:VisibilityModifier OFF - bc - protected int width = 0; - protected int height = 0; - protected int arcwidth = 0; - protected int archeight = 0; - // CheckStyle:VisibilityModifier ON - - /** - * Set the width. - * @param w the value to use. - */ - public void setWidth(int w) { - width = w; - } - - /** - * Set the height. - * @param h the value to use. - */ - public void setHeight(int h) { - height = h; - } - - /** - * Set the arc width. - * @param w the value to use. - */ - public void setArcwidth(int w) { - arcwidth = w; - } - - /** - * Set the arc height. - * @param h the value to use. - */ - public void setArcheight(int h) { - archeight = h; - } - - /** {@inheritDoc}. */ - public PlanarImage executeDrawOperation() { - log("\tCreating Rectangle w=" + width + " h=" + height + " arcw=" - + arcwidth + " arch=" + archeight); - BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR_PRE); - - Graphics2D graphics = (Graphics2D) bi.getGraphics(); - - if (!stroke.equals("transparent")) { - BasicStroke bStroke = new BasicStroke(stroke_width); - graphics.setColor(ColorMapper.getColorByName(stroke)); - graphics.setStroke(bStroke); - - if ((arcwidth != 0) || (archeight != 0)) { - graphics.drawRoundRect(0, 0, width, height, arcwidth, archeight); - } else { - graphics.drawRect(0, 0, width, height); - } - } - - if (!fill.equals("transparent")) { - graphics.setColor(ColorMapper.getColorByName(fill)); - if ((arcwidth != 0) || (archeight != 0)) { - graphics.fillRoundRect(stroke_width, stroke_width, - width - (stroke_width * 2), height - (stroke_width * 2), - arcwidth, archeight); - } else { - graphics.fillRect(stroke_width, stroke_width, - width - (stroke_width * 2), height - (stroke_width * 2)); - } - } - - - final int size = instructions.size(); - for (int i = 0; i < size; i++) { - ImageOperation instr = ((ImageOperation) instructions.elementAt(i)); - if (instr instanceof DrawOperation) { - PlanarImage img = ((DrawOperation) instr).executeDrawOperation(); - graphics.drawImage(img.getAsBufferedImage(), null, 0, 0); - } else if (instr instanceof TransformOperation) { - graphics = (Graphics2D) bi.getGraphics(); - PlanarImage image - = ((TransformOperation) instr) - .executeTransformOperation(PlanarImage.wrapRenderedImage(bi)); - bi = image.getAsBufferedImage(); - } - } - return PlanarImage.wrapRenderedImage(bi); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Rotate.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Rotate.java deleted file mode 100644 index 3013bde4..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Rotate.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.types.optional.image; - -import java.awt.image.BufferedImage; -import java.awt.image.renderable.ParameterBlock; - -import javax.media.jai.InterpolationNearest; -import javax.media.jai.JAI; -import javax.media.jai.PlanarImage; - -/** - * ImageOperation to rotate an image by a certain degree - * - * @see org.apache.tools.ant.taskdefs.optional.image.Image - */ -public class Rotate extends TransformOperation implements DrawOperation { - private static final float HALF_CIRCLE = 180.0F; - - // CheckStyle:VisibilityModifier OFF - bc - protected float angle = 0.0F; - // CheckStyle:VisibilityModifier ON - - /** - * Sets the angle of rotation in degrees. - * @param ang The angle at which to rotate the image - */ - public void setAngle(String ang) { - angle = Float.parseFloat(ang); - } - - - /** - * Rotate an image. - * @param image the image to rotate. - * @return the rotated image. - */ - public PlanarImage performRotate(PlanarImage image) { - float tAngle = (float) (angle * (Math.PI / HALF_CIRCLE)); - ParameterBlock pb = new ParameterBlock(); - pb.addSource(image); - pb.add(0.0F); - pb.add(0.0F); - pb.add(tAngle); - pb.add(new InterpolationNearest()); - return JAI.create("Rotate", pb, null); - } - - - /** - * Performs the image rotation when being handled as a TransformOperation. - * @param image The image to perform the transformation on. - * @return the transformed image. - */ - public PlanarImage executeTransformOperation(PlanarImage image) { - BufferedImage bi = null; - final int size = instructions.size(); - for (int i = 0; i < size; i++) { - ImageOperation instr = ((ImageOperation) instructions.elementAt(i)); - if (instr instanceof DrawOperation) { - // If this TransformOperation has DrawOperation children - // then Rotate the first child and return. - System.out.println("Execing Draws"); - PlanarImage op = ((DrawOperation) instr).executeDrawOperation(); - image = performRotate(op); - return image; - } else if (instr instanceof TransformOperation) { - bi = image.getAsBufferedImage(); - System.out.println("Execing Transforms"); - image = ((TransformOperation) instr) - .executeTransformOperation(PlanarImage.wrapRenderedImage(bi)); - bi = image.getAsBufferedImage(); - } - } - System.out.println("Execing as TransformOperation"); - image = performRotate(image); - System.out.println(image); - return image; - } - - /** - * Performs the image rotation when being handled as a DrawOperation. - * It absolutely requires that there be a DrawOperation nested beneath it, - * but only the FIRST DrawOperation will be handled since it can only return - * ONE image. - * @return the image. - */ - public PlanarImage executeDrawOperation() { - final int size = instructions.size(); - for (int i = 0; i < size; i++) { - ImageOperation instr = ((ImageOperation) instructions.elementAt(i)); - if (instr instanceof DrawOperation) { - // If this TransformOperation has DrawOperation children - // then Rotate the first child and return. - PlanarImage op = ((DrawOperation) instr).executeDrawOperation(); - op = performRotate(op); - return op; - } - } - return null; - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Scale.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Scale.java deleted file mode 100644 index 532694d6..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Scale.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.types.optional.image; - -import java.awt.image.BufferedImage; -import java.awt.image.renderable.ParameterBlock; - -import javax.media.jai.JAI; -import javax.media.jai.PlanarImage; - -import org.apache.tools.ant.types.EnumeratedAttribute; - -/** - * - * @see org.apache.tools.ant.taskdefs.optional.image.Image - */ -public class Scale extends TransformOperation implements DrawOperation { - private static final int HUNDRED = 100; - - private String widthStr = "100%"; - private String heightStr = "100%"; - private boolean xPercent = true; - private boolean yPercent = true; - private String proportions = "ignore"; - - /** Enumerated class for proportions attribute. */ - public static class ProportionsAttribute extends EnumeratedAttribute { - /** {@inheritDoc}. */ - public String[] getValues() { - return new String[] {"ignore", "width", "height", "cover", "fit"}; - } - } - - /** - * Sets the behaviour regarding the image proportions. - * @param pa the enumerated value. - */ - public void setProportions(ProportionsAttribute pa) { - proportions = pa.getValue(); - } - - /** - * Sets the width of the image, either as an integer or a %. - * Defaults to 100%. - * @param width the value to use. - */ - public void setWidth(String width) { - widthStr = width; - } - - /** - * Sets the height of the image, either as an integer or a %. Defaults to 100%. - * @param height the value to use. - */ - public void setHeight(String height) { - heightStr = height; - } - - /** - * Get the width. - * @return the value converted from the width string. - */ - public float getWidth() { - float width = 0.0F; - int percIndex = widthStr.indexOf('%'); - if (percIndex > 0) { - width = Float.parseFloat(widthStr.substring(0, percIndex)); - xPercent = true; - return width / HUNDRED; - } else { - xPercent = false; - return Float.parseFloat(widthStr); - } - } - - /** - * Get the height. - * @return the value converted from the height string. - */ - public float getHeight() { - int percIndex = heightStr.indexOf('%'); - if (percIndex > 0) { - float height = Float.parseFloat(heightStr.substring(0, percIndex)); - yPercent = true; - return height / HUNDRED; - } else { - yPercent = false; - return Float.parseFloat(heightStr); - } - } - - /** - * Scale an image. - * @param image the image to scale. - * @return the scaled image. - */ - public PlanarImage performScale(PlanarImage image) { - ParameterBlock pb = new ParameterBlock(); - pb.addSource(image); - float xFl = getWidth(); - float yFl = getHeight(); - - if (!xPercent) { - xFl = (xFl / image.getWidth()); - } - if (!yPercent) { - yFl = (yFl / image.getHeight()); - } - - if ("width".equals(proportions)) { - yFl = xFl; - } else if ("height".equals(proportions)) { - xFl = yFl; - } else if ("fit".equals(proportions)) { - yFl = Math.min(xFl, yFl); - xFl = yFl; - } else if ("cover".equals(proportions)) { - yFl = Math.max(xFl, yFl); - xFl = yFl; - } - - pb.add(new Float(xFl)); - pb.add(new Float(yFl)); - - log("\tScaling to " + (xFl * HUNDRED) + "% x " - + (yFl * HUNDRED) + "%"); - - return JAI.create("scale", pb); - } - - - /** {@inheritDoc}. */ - public PlanarImage executeTransformOperation(PlanarImage image) { - BufferedImage bi = null; - final int size = instructions.size(); - for (int i = 0; i < size; i++) { - ImageOperation instr = ((ImageOperation) instructions.elementAt(i)); - if (instr instanceof DrawOperation) { - return performScale(image); - } else if (instr instanceof TransformOperation) { - bi = image.getAsBufferedImage(); - image = ((TransformOperation) instr) - .executeTransformOperation(PlanarImage.wrapRenderedImage(bi)); - bi = image.getAsBufferedImage(); - } - } - return performScale(image); - } - - - /** {@inheritDoc}. */ - public PlanarImage executeDrawOperation() { - final int size = instructions.size(); - for (int i = 0; i < size; i++) { - ImageOperation instr = ((ImageOperation) instructions.elementAt(i)); - if (instr instanceof DrawOperation) { - PlanarImage image = null; - // If this TransformOperation has DrawOperation children - // then Rotate the first child and return. - performScale(image); - return image; - } - } - return null; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Text.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Text.java deleted file mode 100644 index 869fbac1..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Text.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.types.optional.image; - -import java.awt.Color; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics2D; -import java.awt.RenderingHints; -import java.awt.image.BufferedImage; - -import javax.media.jai.PlanarImage; - -/** - * - * @see org.apache.tools.ant.taskdefs.optional.image.Image - */ -public class Text extends ImageOperation implements DrawOperation { - private static final int DEFAULT_POINT = 10; - - private String strText = ""; - private String font = "Arial"; - private int point = DEFAULT_POINT; - private boolean bold = false; - private boolean italic = false; - private String color = "black"; - - /** - * Set the string to be used as text. - * @param str the string to be used. - */ - public void setString(String str) { - strText = str; - } - - /** - * Set the font to be used to draw the text. - * @param f the font to be used. - */ - public void setFont(String f) { - font = f; - } - - /** - * Set the number of points to be used. - * @param p an integer value as a string. - */ - public void setPoint(String p) { - point = Integer.parseInt(p); - } - - /** - * Set the color of the text. - * @param c the color name. - */ - public void setColor(String c) { - color = c; - } - - /** - * @todo is this used? - * @param state not used at the moment. - */ - public void setBold(boolean state) { - bold = state; - } - - /** - * @todo is this used? - * @param state not used at the moment. - */ - public void setItalic(boolean state) { - italic = state; - } - - /** - * Draw the text. - * @return the resultant image. - */ - public PlanarImage executeDrawOperation() { - log("\tCreating Text \"" + strText + "\""); - - Color couloir = ColorMapper.getColorByName(color); - int width = 1; - int height = 1; - - BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR_PRE); - Graphics2D graphics = (Graphics2D) bi.getGraphics(); - graphics.setRenderingHint( - RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - graphics.setRenderingHint( - RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); - Font f = new Font(font, Font.PLAIN, point); - FontMetrics fmetrics = graphics.getFontMetrics(f); - height = fmetrics.getMaxAscent() + fmetrics.getMaxDescent(); - width = fmetrics.stringWidth(strText); - - - bi = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR_PRE); - graphics = (Graphics2D) bi.getGraphics(); - - graphics.setRenderingHint( - RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - graphics.setRenderingHint( - RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); - - graphics.setFont(f); - graphics.setColor(couloir); - graphics.drawString(strText, 0, height - fmetrics.getMaxDescent()); - PlanarImage image = PlanarImage.wrapRenderedImage(bi); - return image; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/TransformOperation.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/TransformOperation.java deleted file mode 100644 index 896e5d10..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/TransformOperation.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.types.optional.image; - -import javax.media.jai.PlanarImage; - -/** - * - * @see org.apache.tools.ant.taskdefs.optional.image.Image - */ -public abstract class TransformOperation extends ImageOperation { - /** - * Performs the transformations. - * @param img The image to perform the transformation on. - * @return the transformed image. - */ - public abstract PlanarImage executeTransformOperation(PlanarImage img); - - /** {@inheritDoc}. */ - public void addRectangle(Rectangle instr) { - instructions.add(instr); - } -} |