diff --git a/README.txt b/README.txt deleted file mode 100644 index ca341b3..0000000 --- a/README.txt +++ /dev/null @@ -1,2 +0,0 @@ -# javabegining -Начальные шаги в Java diff --git a/VGViewer/build.xml b/VGViewer/build.xml deleted file mode 100644 index b109f13..0000000 --- a/VGViewer/build.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - Builds, tests, and runs the project VGViewer. - - - diff --git a/VGViewer/manifest.mf b/VGViewer/manifest.mf deleted file mode 100644 index 328e8e5..0000000 --- a/VGViewer/manifest.mf +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -X-COMMENT: Main-Class will be added automatically by build - diff --git a/VGViewer/nbproject/build-impl.xml b/VGViewer/nbproject/build-impl.xml deleted file mode 100644 index 3a2dfe1..0000000 --- a/VGViewer/nbproject/build-impl.xml +++ /dev/null @@ -1,1768 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No tests executed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - Must select one file in the IDE or set profile.class - This target only works when run from inside the NetBeans IDE. - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - - - Must select some files in the IDE or set test.includes - - - - - Must select one file in the IDE or set run.class - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - Must select some files in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - Must select one file in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/VGViewer/nbproject/genfiles.properties b/VGViewer/nbproject/genfiles.properties deleted file mode 100644 index 9f4cf0f..0000000 --- a/VGViewer/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=785ba29d -build.xml.script.CRC32=93d8932e -build.xml.stylesheet.CRC32=f85dc8f2@1.89.1.48 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=785ba29d -nbproject/build-impl.xml.script.CRC32=ccb11652 -nbproject/build-impl.xml.stylesheet.CRC32=3a2fa800@1.89.1.48 diff --git a/VGViewer/nbproject/project.properties b/VGViewer/nbproject/project.properties deleted file mode 100644 index 78660a9..0000000 --- a/VGViewer/nbproject/project.properties +++ /dev/null @@ -1,117 +0,0 @@ -annotation.processing.enabled=true -annotation.processing.enabled.in.editor=false -annotation.processing.processors.list= -annotation.processing.run.all.processors=true -annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output -application.title=VGViewer -application.vendor=grfc -auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -# Uncomment to specify the preferred debugger connection transport: -#debug.transport=dt_socket -debug.classpath=\ - ${run.classpath} -debug.modulepath=\ - ${run.modulepath} -debug.test.classpath=\ - ${run.test.classpath} -debug.test.modulepath=\ - ${run.test.modulepath} -# Files in build.classes.dir which should be excluded from distribution jar -dist.archive.excludes= -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/VGViewer.jar -dist.javadoc.dir=${dist.dir}/javadoc -dist.jlink.dir=${dist.dir}/jlink -dist.jlink.output=${dist.jlink.dir}/VGViewer -endorsed.classpath= -excludes= -includes=** -jar.archive.disabled=${jnlp.enabled} -jar.compress=false -jar.index=${jnlp.enabled} -javac.classpath= -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.external.vm=true -javac.modulepath= -javac.processormodulepath= -javac.processorpath=\ - ${javac.classpath} -javac.source=1.8 -javac.target=1.8 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -javac.test.modulepath=\ - ${javac.modulepath} -javac.test.processorpath=\ - ${javac.test.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding=${source.encoding} -javadoc.html5=false -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -# The jlink additional root modules to resolve -jlink.additionalmodules= -# The jlink additional command line parameters -jlink.additionalparam= -jlink.launcher=true -jlink.launcher.name=VGViewer -jnlp.codebase.type=no.codebase -jnlp.descriptor=application -jnlp.enabled=false -jnlp.mixed.code=default -jnlp.offline-allowed=false -jnlp.signed=false -jnlp.signing= -jnlp.signing.alias= -jnlp.signing.keystore= -main.class=ru.grfc.edu.vgviewer.VGViewer -# Optional override of default Application-Library-Allowable-Codebase attribute identifying the locations where your signed RIA is expected to be found. -manifest.custom.application.library.allowable.codebase= -# Optional override of default Caller-Allowable-Codebase attribute identifying the domains from which JavaScript code can make calls to your RIA without security prompts. -manifest.custom.caller.allowable.codebase= -# Optional override of default Codebase manifest attribute, use to prevent RIAs from being repurposed -manifest.custom.codebase= -# Optional override of default Permissions manifest attribute (supported values: sandbox, all-permissions) -manifest.custom.permissions= -manifest.file=manifest.mf -meta.inf.dir=${src.dir}/META-INF -mkdist.disabled=false -platform.active=default_platform -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project. -# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. -# To set system properties for unit tests define test-sys-prop.name=value: -run.jvmargs= -run.modulepath=\ - ${javac.modulepath} -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -run.test.modulepath=\ - ${javac.test.modulepath} -source.encoding=UTF-8 -src.dir=src -test.src.dir=test diff --git a/VGViewer/nbproject/project.xml b/VGViewer/nbproject/project.xml deleted file mode 100644 index f059769..0000000 --- a/VGViewer/nbproject/project.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - org.netbeans.modules.java.j2seproject - - - VGViewer - - - - - - - - - diff --git a/VGViewer/src/ru/grfc/edu/vgviewer/MainWindow.java b/VGViewer/src/ru/grfc/edu/vgviewer/MainWindow.java deleted file mode 100644 index a37525f..0000000 --- a/VGViewer/src/ru/grfc/edu/vgviewer/MainWindow.java +++ /dev/null @@ -1,27 +0,0 @@ -package ru.grfc.edu.vgviewer; - -import java.awt.Frame; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; - -/** - * - * @author gsv - */ -public class MainWindow extends Frame { - - public MainWindow(String formTitle) { - this.setTitle(formTitle); - WindowListener listener = new MainWindowListener(); - addWindowListener(listener); - } - - private class MainWindowListener extends WindowAdapter { - - @Override - public void windowClosing(WindowEvent e) { - dispose(); - } - } -} diff --git a/VGViewer/src/ru/grfc/edu/vgviewer/VGViewer.java b/VGViewer/src/ru/grfc/edu/vgviewer/VGViewer.java index 0e7fca2..9b18217 100644 --- a/VGViewer/src/ru/grfc/edu/vgviewer/VGViewer.java +++ b/VGViewer/src/ru/grfc/edu/vgviewer/VGViewer.java @@ -11,11 +11,33 @@ import java.io.FileOutputStream; import java.io.FileReader; import java.io.FileWriter; +import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.ArrayList; import java.util.List; +import java.util.Random; import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; +import ru.grfc.edu.vgviewer.figures.Coordinate; import ru.grfc.edu.vgviewer.figures.Ellipse; import ru.grfc.edu.vgviewer.figures.Figure; import ru.grfc.edu.vgviewer.figures.Line; @@ -147,7 +169,7 @@ public void actionPerformed(ActionEvent e) { @Override public void actionPerformed(ActionEvent e) { JFileChooser fileopen = new JFileChooser(); - File file = null; + File file; int ret = fileopen.showDialog(null, "Открыть файл"); if (ret == JFileChooser.APPROVE_OPTION) { file = fileopen.getSelectedFile(); @@ -194,7 +216,7 @@ public void actionPerformed(ActionEvent e) { @Override public void actionPerformed(ActionEvent e) { JFileChooser fileopen = new JFileChooser(); - File file = null; + File file; int ret = fileopen.showDialog(null, "Сохранить в файл"); if (ret == JFileChooser.APPROVE_OPTION) { file = fileopen.getSelectedFile(); @@ -258,35 +280,326 @@ public void actionPerformed(ActionEvent e) { } }); + // Пункт меню "Open xml with SAX" для загрузки данных, сохраненных в xml файл + MenuItem oXmlSax = new MenuItem("Open xml with SAX"); + oXmlSax.addActionListener(new ActionListener() { + long startTime = 0; + long endTime = 0; + + @Override + public void actionPerformed(ActionEvent e) { + class XMLHandler extends DefaultHandler { + + private String w, h, isFilled, fx, fy, px, py, color, text, tx, ty, lastElementName, figureParamStr; + + @Override + public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { + switch (qName) { + case ("line"): + fx = attributes.getValue("x"); + fy = attributes.getValue("y"); + color = attributes.getValue("color"); + break; + case ("rectangle"): + w = attributes.getValue("width"); + h = attributes.getValue("height"); + isFilled = attributes.getValue("isFilled"); + color = attributes.getValue("color"); + break; + case ("point"): + px = attributes.getValue("x"); + py = attributes.getValue("y"); + break; + case ("label"): + tx = attributes.getValue("x"); + ty = attributes.getValue("y"); + } + lastElementName = qName; + } + + @Override + public void characters(char[] ch, int start, int length) throws SAXException { + if ("label".equals(lastElementName)) { + String information = new String(ch, start, length); + information = information.replace("\n", "").trim(); + text = information; + } + lastElementName = ""; + } + + @Override + public void endElement(String uri, String localName, + String qName) throws SAXException { + if ("line".equals(qName)) { + figureParamStr = "fx=" + fx + " fy=" + fy + " lx=" + px + " ly=" + py + " color=" + color + + " text=" + text + " tx=" + tx + " ty=" + ty; + + figuresToPrint.add(NormalFigureFactory.getFigure(FigureEnum.LINE, figureParamStr)); + } + if ("rectangle".equals(qName)) { + figureParamStr = "w=" + w + " h=" + h + " fx=" + px + " fy=" + py + " color=" + color + + " fill=" + isFilled + " text=" + text + " tx=" + tx + " ty=" + ty; + figuresToPrint.add(NormalFigureFactory.getFigure(FigureEnum.RECTANGLE, figureParamStr)); + } + } + } + + JFileChooser fileopen = new JFileChooser(); + File file; + int ret = fileopen.showDialog(null, "Открыть файл"); + if (ret == JFileChooser.APPROVE_OPTION) { + file = fileopen.getSelectedFile(); + try { + SAXParserFactory factory = SAXParserFactory.newInstance(); + SAXParser parser = factory.newSAXParser(); + XMLHandler handler = new XMLHandler(); + figuresToPrint.clear(); + startTime = System.currentTimeMillis(); + parser.parse(file, handler); + endTime = System.currentTimeMillis(); + if (figuresToPrint.size() > 1000) { + JOptionPane.showMessageDialog(null, "Время чтения xml файла: " + (endTime - startTime) / 1000.0 + " c"); + } + } catch (ParserConfigurationException | SAXException | IOException se) { + } + canvas.repaint(); + } + } + }); + + // Пункт меню "Open xml with DOM" для загрузки данных, сохраненных в xml файл + MenuItem oXmlDom = new MenuItem("Open xml with DOM"); + oXmlDom.addActionListener(new ActionListener() { + long startTime = 0; + long endTime = 0; + + @Override + public void actionPerformed(ActionEvent e) { + + JFileChooser fileopen = new JFileChooser(); + File file; + int ret = fileopen.showDialog(null, "Открыть файл"); + if (ret == JFileChooser.APPROVE_OPTION) { + file = fileopen.getSelectedFile(); + + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + figuresToPrint.clear(); + startTime = System.currentTimeMillis(); + Document document = builder.parse(file); + String figureParamStr, w, h, color, fx, fy, isFilled; + String px = null; + String py = null; + String text = null; + String tx = null; + String ty = null; + + // Получение списка всех элементов line внутри корневого элемента + NodeList lineElements = document.getDocumentElement().getElementsByTagName("line"); + + for (int i = 0; i < lineElements.getLength(); i++) { + Node line = lineElements.item(i); + NamedNodeMap lineAttributes = line.getAttributes(); + fx = lineAttributes.getNamedItem("x").getNodeValue(); + fy = lineAttributes.getNamedItem("y").getNodeValue(); + color = lineAttributes.getNamedItem("color").getNodeValue(); + for (int j = 0; j < line.getChildNodes().getLength(); j++) { + switch (line.getChildNodes().item(j).getNodeName()) { + case ("point"): + NamedNodeMap pointAttributes = line.getChildNodes().item(j).getAttributes(); + px = pointAttributes.getNamedItem("x").getNodeValue(); + py = pointAttributes.getNamedItem("y").getNodeValue(); + break; + case ("label"): + NamedNodeMap labelAttributes = line.getChildNodes().item(j).getAttributes(); + tx = labelAttributes.getNamedItem("x").getNodeValue(); + ty = labelAttributes.getNamedItem("y").getNodeValue(); + text = line.getChildNodes().item(j).getTextContent(); + break; + } + + } + figureParamStr = "fx=" + fx + " fy=" + fy + " lx=" + px + " ly=" + py + " color=" + color + + " text=" + text + " tx=" + tx + " ty=" + ty; + + figuresToPrint.add(NormalFigureFactory.getFigure(FigureEnum.LINE, figureParamStr)); + } + + // Получение списка всех элементов rectangle внутри корневого элемента + NodeList recElements = document.getDocumentElement().getElementsByTagName("rectangle"); + for (int i = 0; i < recElements.getLength(); i++) { + Node rec = recElements.item(i); + NamedNodeMap recAttributes = rec.getAttributes(); + w = recAttributes.getNamedItem("width").getNodeValue(); + h = recAttributes.getNamedItem("height").getNodeValue(); + isFilled = recAttributes.getNamedItem("isFilled").getNodeValue(); + color = recAttributes.getNamedItem("color").getNodeValue(); + for (int j = 0; j < rec.getChildNodes().getLength(); j++) { + switch (rec.getChildNodes().item(j).getNodeName()) { + case ("point"): + NamedNodeMap pointAttributes = rec.getChildNodes().item(j).getAttributes(); + px = pointAttributes.getNamedItem("x").getNodeValue(); + py = pointAttributes.getNamedItem("y").getNodeValue(); + break; + case ("label"): + NamedNodeMap labelAttributes = rec.getChildNodes().item(j).getAttributes(); + tx = labelAttributes.getNamedItem("x").getNodeValue(); + ty = labelAttributes.getNamedItem("y").getNodeValue(); + text = rec.getChildNodes().item(j).getTextContent(); + break; + } + + } + figureParamStr = "w=" + w + " h=" + h + " fx=" + px + " fy=" + py + " color=" + color + + " fill=" + isFilled + " text=" + text + " tx=" + tx + " ty=" + ty; + figuresToPrint.add(NormalFigureFactory.getFigure(FigureEnum.RECTANGLE, figureParamStr)); + } + endTime = System.currentTimeMillis(); + if (figuresToPrint.size() > 1000) { + JOptionPane.showMessageDialog(null, "Время чтения xml файла: " + (endTime - startTime) / 1000.0 + " c"); + } + } catch (ParserConfigurationException | SAXException | IOException se) { + } + canvas.repaint(); + } + } + } + ); + + // Пункт меню "Save xml" для сохранения данных в xml файл + MenuItem sXml = new MenuItem("Save xml"); + + sXml.addActionListener(new ActionListener() { + long startTime = 0; + long endTime = 0; + + @Override + public void actionPerformed(ActionEvent e) { + JFileChooser fileopen = new JFileChooser(); + File file = null; + int ret = fileopen.showDialog(null, "Сохранить в файл"); + if (ret == JFileChooser.APPROVE_OPTION) { + file = fileopen.getSelectedFile(); + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + Document doc = factory.newDocumentBuilder().newDocument(); + Element figures = doc.createElement("figures"); + doc.appendChild(figures); + for (Figure figure : figuresToPrint) { + switch ((figure.getClass()).getSimpleName()) { + case ("Line"): + Line figLine = (Line) figure; + Element line = doc.createElement("line"); + line.setAttribute("x", String.valueOf(figLine.getFirstPoint().getX())); + line.setAttribute("y", String.valueOf(figLine.getFirstPoint().getY())); + line.setAttribute("color", "rgb(" + figLine.getColor().getRed() + "," + figLine.getColor().getGreen() + "," + figLine.getColor().getBlue() + ")"); + figures.appendChild(line); + Element linePoint = doc.createElement("point"); + linePoint.setAttribute("x", String.valueOf(figLine.getLastPoint().getX())); + linePoint.setAttribute("y", String.valueOf(figLine.getLastPoint().getY())); + line.appendChild(linePoint); + Element label = doc.createElement("label"); + label.setAttribute("x", String.valueOf(figLine.getTextPoint().getX())); + label.setAttribute("y", String.valueOf(figLine.getTextPoint().getY())); + label.appendChild(doc.createTextNode(figLine.getText())); + line.appendChild(label); + break; + case ("Rectangle"): + Rectangle figRectangle = (Rectangle) figure; + Element rectangle = doc.createElement("rectangle"); + rectangle.setAttribute("width", String.valueOf(figRectangle.getWidth())); + rectangle.setAttribute("height", String.valueOf(figRectangle.getHeight())); + rectangle.setAttribute("isFilled", String.valueOf(figRectangle.isFill())); + rectangle.setAttribute("color", "rgb(" + figRectangle.getColor().getRed() + "," + figRectangle.getColor().getGreen() + "," + figRectangle.getColor().getBlue() + ")"); + figures.appendChild(rectangle); + Element recPoint = doc.createElement("point"); + recPoint.setAttribute("x", String.valueOf(figRectangle.getFirstPoint().getX())); + recPoint.setAttribute("y", String.valueOf(figRectangle.getFirstPoint().getY())); + rectangle.appendChild(recPoint); + Element recLabel = doc.createElement("label"); + recLabel.setAttribute("x", String.valueOf(figRectangle.getTextPoint().getX())); + recLabel.setAttribute("y", String.valueOf(figRectangle.getTextPoint().getY())); + recLabel.appendChild(doc.createTextNode(figRectangle.getText())); + rectangle.appendChild(recLabel); + break; + } + } + try { + Transformer transformer = TransformerFactory.newInstance().newTransformer(); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.transform(new DOMSource(doc), new StreamResult(file)); + } catch (Exception ep) { + + } + + } catch (ParserConfigurationException pce) { + + } + } + } + }); + + // Пункт меню "To generate figures" для генерации фигур + MenuItem fGen = new MenuItem("To generate 20000 figures"); + fGen.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + + figuresToPrint.clear(); + Random random = new Random(); + + // Создадим 10000 линий и прямоугольников + for (int i = 0; i < 10000; i++) { + Coordinate lineFirstPoint = new Coordinate(random.nextInt(f.getWidth() - 1), random.nextInt(f.getHeight() - 1)); + Coordinate lineLastPoint = new Coordinate(random.nextInt(f.getWidth() - 1), random.nextInt(f.getHeight() - 1)); + String text = "" + (i + 1); + Coordinate lineTextPoint = new Coordinate(lineFirstPoint.getX() + 10, lineFirstPoint.getY()); + Line line = new Line(lineFirstPoint, lineLastPoint, Color.GREEN, text, lineTextPoint); + figuresToPrint.add(line); + int width = random.nextInt(150) + 20; + int height = random.nextInt(150) + 20; + Coordinate recFirstPoint = new Coordinate(random.nextInt(f.getWidth() - 1), random.nextInt(f.getHeight() - 1)); + Coordinate recTextPoint = new Coordinate(recFirstPoint.getX() + 10, recFirstPoint.getY()); + Rectangle rectangle = new Rectangle(width, height, recFirstPoint, Color.RED, false, text, recTextPoint); + figuresToPrint.add(rectangle); + } + canvas.repaint(); + } + } + ); + fileMenu.add(oSer); fileMenu.add(sSer); fileMenu.add(oTxt); fileMenu.add(sTxt); + fileMenu.add(oXmlSax); + fileMenu.add(oXmlDom); + fileMenu.add(sXml); + fileMenu.add(fGen); mbar.add(fileMenu); f.setMenuBar(mbar); - Panel topLeftPanel = new Panel(); topLeftPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); topLeftPanel.add(choiceFigureLabel); topLeftPanel.add(choiceFigure); topLeftPanel.add(imputParamTextField); - Panel topRigthPanel = new Panel(); topRigthPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); topRigthPanel.add(addFigureButton); - Panel topPanel = new Panel(); topPanel.setLayout(new BorderLayout()); topPanel.add(topLeftPanel, BorderLayout.WEST); topPanel.add(topRigthPanel, BorderLayout.EAST); - f.add(topPanel, BorderLayout.NORTH); f.add(canvas, BorderLayout.CENTER); f.setSize(800, 500); f.setVisible(true); } - private FigureEnum getFigureEnumElement(String figureName) { + private FigureEnum + getFigureEnumElement(String figureName) { FigureEnum figureEnum = null; for (FigureEnum value : FigureEnum.values()) { if (value.equalsName(figureName)) { diff --git a/VGViewer/src/ru/grfc/edu/vgviewer/ViewerCanvas.java b/VGViewer/src/ru/grfc/edu/vgviewer/ViewerCanvas.java deleted file mode 100644 index 7642fd5..0000000 --- a/VGViewer/src/ru/grfc/edu/vgviewer/ViewerCanvas.java +++ /dev/null @@ -1,32 +0,0 @@ -package ru.grfc.edu.vgviewer; - -import java.awt.*; -import java.util.List; -import ru.grfc.edu.vgviewer.figures.Figure; - -/** - * - * @author gsv - */ -public class ViewerCanvas extends Canvas { - - private List
figures; - - public void setFigures(List
figures) { - this.figures = figures; - } - - @Override - public void paint(Graphics g) { - int widthToPrint = this.size().width - 1; - int heightToPrint = this.size().height - 1; - g.setColor(Color.RED); - g.drawRect(0, 0, widthToPrint, heightToPrint); - - if (figures != null) { - figures.forEach((figure) -> { - figure.draw(g); - }); - } - } -} diff --git a/VGViewer/src/ru/grfc/edu/vgviewer/figures/Coordinate.java b/VGViewer/src/ru/grfc/edu/vgviewer/figures/Coordinate.java index 08c80fb..28360ba 100644 --- a/VGViewer/src/ru/grfc/edu/vgviewer/figures/Coordinate.java +++ b/VGViewer/src/ru/grfc/edu/vgviewer/figures/Coordinate.java @@ -35,4 +35,4 @@ public void setX(int x) { public void setY(int y) { this.y = y; } -} +} \ No newline at end of file diff --git a/VGViewer/src/ru/grfc/edu/vgviewer/figures/Ellipse.java b/VGViewer/src/ru/grfc/edu/vgviewer/figures/Ellipse.java index f250488..d68d0da 100644 --- a/VGViewer/src/ru/grfc/edu/vgviewer/figures/Ellipse.java +++ b/VGViewer/src/ru/grfc/edu/vgviewer/figures/Ellipse.java @@ -56,4 +56,4 @@ public String getName() { return width == height ? "Круг" : "Эллипс"; } -} +} \ No newline at end of file diff --git a/VGViewer/src/ru/grfc/edu/vgviewer/figures/Figure.java b/VGViewer/src/ru/grfc/edu/vgviewer/figures/Figure.java index 746c38e..d59318d 100644 --- a/VGViewer/src/ru/grfc/edu/vgviewer/figures/Figure.java +++ b/VGViewer/src/ru/grfc/edu/vgviewer/figures/Figure.java @@ -62,4 +62,4 @@ public Coordinate getTextPoint() { //имя фигуры public abstract String getName(); -} +} \ No newline at end of file diff --git a/VGViewer/src/ru/grfc/edu/vgviewer/figures/Line.java b/VGViewer/src/ru/grfc/edu/vgviewer/figures/Line.java index e663b8a..f91dcd7 100644 --- a/VGViewer/src/ru/grfc/edu/vgviewer/figures/Line.java +++ b/VGViewer/src/ru/grfc/edu/vgviewer/figures/Line.java @@ -38,4 +38,4 @@ public void draw(Graphics g) { public String getName() { return "Линия"; } -} +} \ No newline at end of file diff --git a/VGViewer/src/ru/grfc/edu/vgviewer/figures/Parallelogram.java b/VGViewer/src/ru/grfc/edu/vgviewer/figures/Parallelogram.java index 7f5e518..6926963 100644 --- a/VGViewer/src/ru/grfc/edu/vgviewer/figures/Parallelogram.java +++ b/VGViewer/src/ru/grfc/edu/vgviewer/figures/Parallelogram.java @@ -56,4 +56,4 @@ public String getName() { return "Параллелограм"; } -} +} \ No newline at end of file diff --git a/VGViewer/src/ru/grfc/edu/vgviewer/figures/Rectangle.java b/VGViewer/src/ru/grfc/edu/vgviewer/figures/Rectangle.java index f2d3b62..e227c49 100644 --- a/VGViewer/src/ru/grfc/edu/vgviewer/figures/Rectangle.java +++ b/VGViewer/src/ru/grfc/edu/vgviewer/figures/Rectangle.java @@ -49,4 +49,4 @@ public void draw(Graphics g) { public String getName() { return width == height ? "Квадрат" : "Прямоугольник"; } -} +} \ No newline at end of file diff --git a/VGViewer/src/ru/grfc/edu/vgviewer/figures/Rhombus.java b/VGViewer/src/ru/grfc/edu/vgviewer/figures/Rhombus.java index fe95834..d828bce 100644 --- a/VGViewer/src/ru/grfc/edu/vgviewer/figures/Rhombus.java +++ b/VGViewer/src/ru/grfc/edu/vgviewer/figures/Rhombus.java @@ -41,4 +41,4 @@ public void draw(Graphics g) { public String getName() { return "Ромб"; } -} +} \ No newline at end of file diff --git a/VGViewer/src/ru/grfc/edu/vgviewer/figures/RoundRectangle.java b/VGViewer/src/ru/grfc/edu/vgviewer/figures/RoundRectangle.java index 8d1701f..307718a 100644 --- a/VGViewer/src/ru/grfc/edu/vgviewer/figures/RoundRectangle.java +++ b/VGViewer/src/ru/grfc/edu/vgviewer/figures/RoundRectangle.java @@ -52,4 +52,4 @@ public void draw(Graphics g) { public String getName() { return "Прямоугольник с закругленными краями"; } -} +} \ No newline at end of file diff --git a/VGViewer/src/ru/grfc/edu/vgviewer/figures/support/FigureEnum.java b/VGViewer/src/ru/grfc/edu/vgviewer/figures/support/FigureEnum.java index aa798ac..9ab16d1 100644 --- a/VGViewer/src/ru/grfc/edu/vgviewer/figures/support/FigureEnum.java +++ b/VGViewer/src/ru/grfc/edu/vgviewer/figures/support/FigureEnum.java @@ -82,4 +82,4 @@ public String getTemplate() { public String getRegExp() { return this.regExp; } -} +} \ No newline at end of file diff --git a/VGViewer/src/ru/grfc/edu/vgviewer/figures/support/FigureParams.java b/VGViewer/src/ru/grfc/edu/vgviewer/figures/support/FigureParams.java index 3b2eefd..47030f4 100644 --- a/VGViewer/src/ru/grfc/edu/vgviewer/figures/support/FigureParams.java +++ b/VGViewer/src/ru/grfc/edu/vgviewer/figures/support/FigureParams.java @@ -210,4 +210,4 @@ public static Color stringToColor(final String value) { } } -} +} \ No newline at end of file diff --git a/VGViewer/src/ru/grfc/edu/vgviewer/figures/support/NormalFigureFactory.java b/VGViewer/src/ru/grfc/edu/vgviewer/figures/support/NormalFigureFactory.java index 61006d0..776afc8 100644 --- a/VGViewer/src/ru/grfc/edu/vgviewer/figures/support/NormalFigureFactory.java +++ b/VGViewer/src/ru/grfc/edu/vgviewer/figures/support/NormalFigureFactory.java @@ -46,4 +46,4 @@ public static Figure getFigure(FigureEnum figureType, String parametrs) { } return null; } -} +} \ No newline at end of file diff --git a/a.java b/a.java deleted file mode 100644 index 6043d4a..0000000 --- a/a.java +++ /dev/null @@ -1,31 +0,0 @@ -import java.awt.*; -import java.awt.event.*; - -public class a { - - public static class MainWindow extends Frame { - - public MainWindow() { - WindowListener listener = new MainWindowListener(); - addWindowListener(listener); - } - - private class MainWindowListener extends WindowAdapter { - - @Override - public void windowClosing(WindowEvent e) { - dispose(); - } - - } - - } - - public static void main(String args[]) { - System.out.println("Hello, GRFC!"); - Frame f = new MainWindow(); - f.setSize(300, 300); - f.setVisible(true); - } - -} \ No newline at end of file diff --git a/edu_awt/EduAwtHello/build.xml b/edu_awt/EduAwtHello/build.xml deleted file mode 100644 index 5665951..0000000 --- a/edu_awt/EduAwtHello/build.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - Builds, tests, and runs the project EduAwtHello. - - - diff --git a/edu_awt/EduAwtHello/manifest.mf b/edu_awt/EduAwtHello/manifest.mf deleted file mode 100644 index 328e8e5..0000000 --- a/edu_awt/EduAwtHello/manifest.mf +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -X-COMMENT: Main-Class will be added automatically by build - diff --git a/edu_awt/EduAwtHello/nbproject/build-impl.xml b/edu_awt/EduAwtHello/nbproject/build-impl.xml deleted file mode 100644 index 9854549..0000000 --- a/edu_awt/EduAwtHello/nbproject/build-impl.xml +++ /dev/null @@ -1,1768 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No tests executed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - Must select one file in the IDE or set profile.class - This target only works when run from inside the NetBeans IDE. - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - - - Must select some files in the IDE or set test.includes - - - - - Must select one file in the IDE or set run.class - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - Must select some files in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - Must select one file in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/edu_awt/EduAwtHello/nbproject/genfiles.properties b/edu_awt/EduAwtHello/nbproject/genfiles.properties deleted file mode 100644 index f355584..0000000 --- a/edu_awt/EduAwtHello/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=5774642b -build.xml.script.CRC32=f4e26742 -build.xml.stylesheet.CRC32=f85dc8f2@1.89.1.48 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=5774642b -nbproject/build-impl.xml.script.CRC32=0c620ede -nbproject/build-impl.xml.stylesheet.CRC32=3a2fa800@1.89.1.48 diff --git a/edu_awt/EduAwtHello/nbproject/project.properties b/edu_awt/EduAwtHello/nbproject/project.properties deleted file mode 100644 index 64a7109..0000000 --- a/edu_awt/EduAwtHello/nbproject/project.properties +++ /dev/null @@ -1,95 +0,0 @@ -annotation.processing.enabled=true -annotation.processing.enabled.in.editor=false -annotation.processing.processor.options= -annotation.processing.processors.list= -annotation.processing.run.all.processors=true -annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -# Uncomment to specify the preferred debugger connection transport: -#debug.transport=dt_socket -debug.classpath=\ - ${run.classpath} -debug.modulepath=\ - ${run.modulepath} -debug.test.classpath=\ - ${run.test.classpath} -debug.test.modulepath=\ - ${run.test.modulepath} -# Files in build.classes.dir which should be excluded from distribution jar -dist.archive.excludes= -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/EduAwtHello.jar -dist.javadoc.dir=${dist.dir}/javadoc -dist.jlink.dir=${dist.dir}/jlink -dist.jlink.output=${dist.jlink.dir}/EduAwtHello -excludes= -includes=** -jar.compress=false -javac.classpath= -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.external.vm=true -javac.modulepath= -javac.processormodulepath= -javac.processorpath=\ - ${javac.classpath} -javac.source=11 -javac.target=11 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -javac.test.modulepath=\ - ${javac.modulepath} -javac.test.processorpath=\ - ${javac.test.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding=${source.encoding} -javadoc.html5=false -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -# The jlink additional root modules to resolve -jlink.additionalmodules= -# The jlink additional command line parameters -jlink.additionalparam= -jlink.launcher=true -jlink.launcher.name=EduAwtHello -main.class=ru.grfc.edu.awthello.EduAwtHello -manifest.file=manifest.mf -meta.inf.dir=${src.dir}/META-INF -mkdist.disabled=false -platform.active=default_platform -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project. -# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. -# To set system properties for unit tests define test-sys-prop.name=value: -run.jvmargs= -run.modulepath=\ - ${javac.modulepath} -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -run.test.modulepath=\ - ${javac.test.modulepath} -source.encoding=UTF-8 -src.dir=src -test.src.dir=test diff --git a/edu_awt/EduAwtHello/nbproject/project.xml b/edu_awt/EduAwtHello/nbproject/project.xml deleted file mode 100644 index a4b18c5..0000000 --- a/edu_awt/EduAwtHello/nbproject/project.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - org.netbeans.modules.java.j2seproject - - - EduAwtHello - - - - - - - - - diff --git a/edu_awt/EduAwtHello/src/ru/grfc/edu/awthello/EduAwtHello.java b/edu_awt/EduAwtHello/src/ru/grfc/edu/awthello/EduAwtHello.java deleted file mode 100644 index 7102b2d..0000000 --- a/edu_awt/EduAwtHello/src/ru/grfc/edu/awthello/EduAwtHello.java +++ /dev/null @@ -1,125 +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 ru.grfc.edu.awthello; - -import java.awt.*; -<<<<<<< HEAD -import java.awt.event.*; - -/** - * - * @author Насоновы - */ -public class EduAwtHello { - - public static class MainWindow extends Frame { - - public MainWindow() { - WindowListener listeren = new MainWindowListeren(); - addWindowListener(listeren); - } - - public class MainWindowListeren extends WindowAdapter { - - @Override - public void windowClosing(WindowEvent e) { - dispose(); - } - } - } - - public static class MyCanvas extends Canvas { - - @Override - public void paint(Graphics g) { - int width = getWidth(); - int height = getHeight(); - g.setColor(Color.RED); - g.drawRect(0, 0, width - 1, height - 1); - g.setColor(Color.GREEN); - g.drawLine(0, 0, width - 1, height - 1); - g.drawLine(width - 1, 0, 0, height - 1); - g.setColor(Color.MAGENTA); - g.fillArc(((width -1) / 2 - Math.min(height, width) / 4), ((height -1) / 2 - Math.min(height, width) / 4), Math.min(height, width) / 2, Math.min(height, width) / 2, 0, 360); - g.setColor(Color.YELLOW); - int fontSize = 10; - g.setFont(new Font("Times", 1, fontSize)); - FontMetrics fm = g.getFontMetrics(); - int tWidth = fm.stringWidth("Hello, ГРЧЦ!"); - fontSize = (int) (fontSize * 0.8 * width / tWidth); - g.setFont(new Font("Times", 1, fontSize)); - fm = g.getFontMetrics(); - tWidth = fm.stringWidth("Hello, ГРЧЦ!"); - g.drawString("Hello, ГРЧЦ!", (((width -1) / 2) - (tWidth / 2)), (((height - 1) / 2 ) + (fontSize / 3))); - } - } - - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - // TODO code application logic here - System.out.println("Hello, GRFC!"); - Frame f = new MainWindow(); - f.setSize(300, 300); - f.setVisible(true); - f.add(new MyCanvas()); -======= -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; - -/** - * - * @author Dralina D. - */ -public class EduAwtHello { - - public static void main(String[] args) { - Frame frame = new Frame(); - frame.setSize(300, 300); - frame.addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent e) { - frame.dispose(); - } - }); - - Canvas canvas = new MyCanvas(); - frame.add(canvas); - frame.setVisible(true); - } - - private static class MyCanvas extends Canvas { - - @Override - public void paint(Graphics g) { - int width = getWidth(); - int height = getHeight(); - - g.setColor(Color.red); - g.drawRect(0, 0, width - 1, height - 1); - - g.setColor(Color.green); - g.drawLine(0, 0, width, height); - g.drawLine(0, height, width, 0); - - int d = width > height ? (height / 2) : (width / 2); - g.setColor(Color.black); - g.drawOval((width - d) / 2, (height - d) / 2, d, d); - - String text = "Hello, GRFC!"; - int stringWidth = g.getFontMetrics().stringWidth(text); - Font font = new Font(Font.MONOSPACED, Font.BOLD, (int) (width * 0.8 / (stringWidth / g.getFontMetrics().charWidth('H')))); - g.setFont(font); - g.setColor(Color.magenta); - stringWidth = g.getFontMetrics().stringWidth(text); - int stringHeight = g.getFontMetrics().getHeight(); - g.drawChars(text.toCharArray(), 0, text.length(), width / 2 - stringWidth / 2, height / 2 + stringHeight / 4); - - } ->>>>>>> upstream/master - } -} diff --git a/edu_files/EduFiles/build.xml b/edu_files/EduFiles/build.xml deleted file mode 100644 index 9d35c1f..0000000 --- a/edu_files/EduFiles/build.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - Builds, tests, and runs the project EduFiles. - - - diff --git a/edu_files/EduFiles/data.bin b/edu_files/EduFiles/data.bin deleted file mode 100644 index c6e8bf3..0000000 Binary files a/edu_files/EduFiles/data.bin and /dev/null differ diff --git a/edu_files/EduFiles/in.txt b/edu_files/EduFiles/in.txt deleted file mode 100644 index 1fcbb13..0000000 --- a/edu_files/EduFiles/in.txt +++ /dev/null @@ -1 +0,0 @@ -Andrew \ No newline at end of file diff --git a/edu_files/EduFiles/nbproject/build-impl.xml b/edu_files/EduFiles/nbproject/build-impl.xml deleted file mode 100644 index f1a216c..0000000 --- a/edu_files/EduFiles/nbproject/build-impl.xml +++ /dev/null @@ -1,1768 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No tests executed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - Must select one file in the IDE or set profile.class - This target only works when run from inside the NetBeans IDE. - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - - - Must select some files in the IDE or set test.includes - - - - - Must select one file in the IDE or set run.class - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - Must select some files in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - Must select one file in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/edu_files/EduFiles/nbproject/genfiles.properties b/edu_files/EduFiles/nbproject/genfiles.properties deleted file mode 100644 index 784f614..0000000 --- a/edu_files/EduFiles/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=78264c2d -build.xml.script.CRC32=297507bf -build.xml.stylesheet.CRC32=f85dc8f2@1.89.1.48 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=78264c2d -nbproject/build-impl.xml.script.CRC32=63bab227 -nbproject/build-impl.xml.stylesheet.CRC32=3a2fa800@1.89.1.48 diff --git a/edu_files/EduFiles/nbproject/project.properties b/edu_files/EduFiles/nbproject/project.properties deleted file mode 100644 index a1a266b..0000000 --- a/edu_files/EduFiles/nbproject/project.properties +++ /dev/null @@ -1,95 +0,0 @@ -annotation.processing.enabled=true -annotation.processing.enabled.in.editor=false -annotation.processing.processor.options= -annotation.processing.processors.list= -annotation.processing.run.all.processors=true -annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -# Uncomment to specify the preferred debugger connection transport: -#debug.transport=dt_socket -debug.classpath=\ - ${run.classpath} -debug.modulepath=\ - ${run.modulepath} -debug.test.classpath=\ - ${run.test.classpath} -debug.test.modulepath=\ - ${run.test.modulepath} -# Files in build.classes.dir which should be excluded from distribution jar -dist.archive.excludes= -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/EduFiles.jar -dist.javadoc.dir=${dist.dir}/javadoc -dist.jlink.dir=${dist.dir}/jlink -dist.jlink.output=${dist.jlink.dir}/EduFiles -excludes= -includes=** -jar.compress=false -javac.classpath= -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.external.vm=true -javac.modulepath= -javac.processormodulepath= -javac.processorpath=\ - ${javac.classpath} -javac.source=11 -javac.target=11 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -javac.test.modulepath=\ - ${javac.modulepath} -javac.test.processorpath=\ - ${javac.test.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding=${source.encoding} -javadoc.html5=false -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -# The jlink additional root modules to resolve -jlink.additionalmodules= -# The jlink additional command line parameters -jlink.additionalparam= -jlink.launcher=true -jlink.launcher.name=EduFiles -main.class=EduFiles1Std -manifest.file=manifest.mf -meta.inf.dir=${src.dir}/META-INF -mkdist.disabled=false -platform.active=default_platform -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project. -# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. -# To set system properties for unit tests define test-sys-prop.name=value: -run.jvmargs= -run.modulepath=\ - ${javac.modulepath} -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -run.test.modulepath=\ - ${javac.test.modulepath} -source.encoding=UTF-8 -src.dir=src -test.src.dir=test diff --git a/edu_files/EduFiles/nbproject/project.xml b/edu_files/EduFiles/nbproject/project.xml deleted file mode 100644 index 396554b..0000000 --- a/edu_files/EduFiles/nbproject/project.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - org.netbeans.modules.java.j2seproject - - - EduFiles - - - - - - - - - diff --git a/edu_files/EduFiles/object.bin b/edu_files/EduFiles/object.bin deleted file mode 100644 index b7a1427..0000000 Binary files a/edu_files/EduFiles/object.bin and /dev/null differ diff --git a/edu_files/EduFiles/out.txt b/edu_files/EduFiles/out.txt deleted file mode 100644 index 1fcbb13..0000000 --- a/edu_files/EduFiles/out.txt +++ /dev/null @@ -1 +0,0 @@ -Andrew \ No newline at end of file diff --git a/edu_files/EduFiles/src/EduFiles1Std.java b/edu_files/EduFiles/src/EduFiles1Std.java deleted file mode 100644 index 725d630..0000000 --- a/edu_files/EduFiles/src/EduFiles1Std.java +++ /dev/null @@ -1,19 +0,0 @@ -import java.io.*; - -/* -in.txt -Andrew -*/ - -public class EduFiles1Std { - - public static void main(String[] args) throws IOException { - System.out.print("Enter your name: "); - byte[] line = new byte[1000]; - int count = System.in.read(line); - String hello = "Hello, " + new String(line, 0, count) + "!"; - System.out.println("out:" + hello); - System.err.println("err:" + hello); - } - -} diff --git a/edu_files/EduFiles/src/EduFiles2CopyByte.java b/edu_files/EduFiles/src/EduFiles2CopyByte.java deleted file mode 100644 index 736912e..0000000 --- a/edu_files/EduFiles/src/EduFiles2CopyByte.java +++ /dev/null @@ -1,30 +0,0 @@ -import java.io.*; -import java.util.logging.Level; -import java.util.logging.Logger; - -public class EduFiles2CopyByte { - - public static void main(String[] args) { - try { - FileInputStream in = new FileInputStream("EduFiles1Std.class"); - - try { - FileOutputStream out = new FileOutputStream("EduFiles1Std.bin"); - - int c; - while ((c = in.read()) != -1) { - out.write(c); - } - } catch (IOException ex) { - Logger.getLogger(EduFiles2CopyByte.class.getName()).log(Level.SEVERE, null, ex); - } finally { - //out.close(); - } - } catch (IOException ex) { - Logger.getLogger(EduFiles2CopyByte.class.getName()).log(Level.SEVERE, null, ex); - } finally { - //in.close(); - } - } - -} diff --git a/edu_files/EduFiles/src/EduFiles3Buffered.java b/edu_files/EduFiles/src/EduFiles3Buffered.java deleted file mode 100644 index 508602b..0000000 --- a/edu_files/EduFiles/src/EduFiles3Buffered.java +++ /dev/null @@ -1,39 +0,0 @@ - -import java.io.*; -import java.util.logging.Level; -import java.util.logging.Logger; - -public class EduFiles3Buffered { - - public static void main(String[] args) { - InputStream in = null; - OutputStream out = null; - - try { - in = new BufferedInputStream(new FileInputStream("EduFiles1Std.class"), 1024); - long startTime = System.currentTimeMillis(); - out = new BufferedOutputStream(new FileOutputStream("EduFiles1Std.bin"), 1024); - long endTime = System.currentTimeMillis(); - System.out.println(String.format("delay: %7.3f", (endTime - startTime) / 1000.0)); - int c; - - while ((c = in.read()) != -1) { - out.write(c); - } - } catch (IOException ex) { - Logger.getLogger(EduFiles3Buffered.class.getName()).log(Level.SEVERE, null, ex); - } finally { - try { - if (in != null) { - in.close(); - } - if (out != null) { - out.close(); - } - } catch (IOException ex) { - Logger.getLogger(EduFiles3Buffered.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - -} diff --git a/edu_files/EduFiles/src/EduFiles4Text.java b/edu_files/EduFiles/src/EduFiles4Text.java deleted file mode 100644 index d65916e..0000000 --- a/edu_files/EduFiles/src/EduFiles4Text.java +++ /dev/null @@ -1,24 +0,0 @@ - -import java.io.*; -import java.nio.charset.Charset; -import java.util.logging.Level; -import java.util.logging.Logger; - -public class EduFiles4Text { - - public static void main(String[] args) { - try ( FileReader inputStream = new FileReader("in.txt"); /*, Charset.forName("UTF-8")*/ - FileWriter outputStream = new FileWriter("out.txt");) { - - int c; - while ((c = inputStream.read()) != -1) { - outputStream.write(c); - } - } catch (IOException ex) { - Logger.getLogger(EduFiles4Text.class.getName()).log(Level.SEVERE, null, ex); - } - // interface java.lang.AutoCloseable - // jad - } - -} diff --git a/edu_files/EduFiles/src/EduFiles5Data.java b/edu_files/EduFiles/src/EduFiles5Data.java deleted file mode 100644 index ae2b3e7..0000000 --- a/edu_files/EduFiles/src/EduFiles5Data.java +++ /dev/null @@ -1,57 +0,0 @@ - -import java.io.*; -import java.util.logging.Level; -import java.util.logging.Logger; - -public class EduFiles5Data { - - static final String[] descrs = { - "Java T-shirt", - "Java Mug", - "Duke Juggling Dolls", - "Java Pin", - "Java Key Chain" - }; - static final double[] prices = {19.99, 9.99, 15.99, 3.99, 4.99}; - static final int[] units = {12, 8, 13, 29, 50}; - - public static void main(String[] args) { - String dataFile = "data.bin"; - - try ( DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(dataFile)));) { - for (int i = 0; i < prices.length; i++) { - out.writeUTF(descrs[i]); - out.writeDouble(prices[i]); - out.writeInt(units[i]); - } - } catch (IOException ex) { - Logger.getLogger(EduFiles5Data.class.getName()).log(Level.SEVERE, null, ex); - } - - try ( DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(dataFile)));) { - - String descr; - double price; - int unit; - double total = 0.0; - - try { - while (true) { - descr = in.readUTF(); - price = in.readDouble(); - unit = in.readInt(); - System.out.format("You ordered %d" + " units of %s at $%.2f%n", - unit, descr, price); - total += unit * price; - } - } catch (EOFException e) { - } - System.out.format("Total: " + " $%.2f%n", total); - - } catch (IOException ex) { - Logger.getLogger(EduFiles5Data.class.getName()).log(Level.SEVERE, null, ex); - } - - } - -} diff --git a/edu_files/EduFiles/src/EduFiles6Serializable.java b/edu_files/EduFiles/src/EduFiles6Serializable.java deleted file mode 100644 index 5f66d16..0000000 --- a/edu_files/EduFiles/src/EduFiles6Serializable.java +++ /dev/null @@ -1,55 +0,0 @@ - -import java.io.*; -import java.util.*; -import java.util.logging.Level; -import java.util.logging.Logger; - -public class EduFiles6Serializable { - - static final List orders = new ArrayList(); - - static { - orders.add(new Order("Java T-shirt", 19.99, 12)); - orders.add(new Order("Java Mug", 9.99, 8)); - orders.add(new Order("Duke Juggling Dolls", 15.99, 13)); - orders.add(new Order("Java Pin", 3.99, 29)); - orders.add(new Order("Java Key Chain",4.99, 50)); - } - - public static void main(String[] args) { - String dataFile = "object.bin"; - //ObjectOutputStream - //ObjectInputStream - - try ( ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(dataFile)));) { - for (Order order : orders) { - out.writeObject(order); - } - } catch (IOException ex) { - Logger.getLogger(EduFiles6Serializable.class.getName()).log(Level.SEVERE, null, ex); - } - - try ( ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(dataFile)));) { - - double total = 0.0; - - try { - while (true) { - Order order = (Order) in.readObject(); - System.out.format("You ordered %d" + " units of %s at $%.2f%n", - order.unit, order.descr, order.price); - total += order.unit * order.price; - } - } catch (EOFException e) { - } - System.out.format("Total: " + " $%.2f%n", total); - - } catch (ClassNotFoundException ex) { - Logger.getLogger(EduFiles6Serializable.class.getName()).log(Level.SEVERE, null, ex); - } catch (IOException ex) { - Logger.getLogger(EduFiles6Serializable.class.getName()).log(Level.SEVERE, null, ex); - } - - } - -} diff --git a/edu_files/EduFiles/src/EduFiles7InputSer.java b/edu_files/EduFiles/src/EduFiles7InputSer.java deleted file mode 100644 index 6f82312..0000000 --- a/edu_files/EduFiles/src/EduFiles7InputSer.java +++ /dev/null @@ -1,48 +0,0 @@ - -import java.io.*; -import java.util.logging.Level; -import java.util.logging.Logger; - -/* - * 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. - */ - -/** - * - * @author nag - */ -public class EduFiles7InputSer { - - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - String dataFile = "object.bin"; - //ObjectOutputStream - //ObjectInputStream - - try ( ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(dataFile)));) { - - double total = 0.0; - - try { - while (true) { - Order order = (Order) in.readObject(); - System.out.format("You ordered %d" + " units of %s at $%.2f%n", - order.unit, order.descr, order.price); - total += order.unit * order.price; - } - } catch (EOFException e) { - } - System.out.format("Total: " + " $%.2f%n", total); - - } catch (ClassNotFoundException ex) { - Logger.getLogger(EduFiles7InputSer.class.getName()).log(Level.SEVERE, null, ex); - } catch (IOException ex) { - Logger.getLogger(EduFiles6Serializable.class.getName()).log(Level.SEVERE, null, ex); - } - } - -} diff --git a/edu_files/EduFiles/src/EduFiles9Tests.java b/edu_files/EduFiles/src/EduFiles9Tests.java index 1fe6729..71ed032 100644 --- a/edu_files/EduFiles/src/EduFiles9Tests.java +++ b/edu_files/EduFiles/src/EduFiles9Tests.java @@ -174,4 +174,4 @@ public static double[] getTimeReadWrite(String inFile, String outFile, int amoun System.out.println(); return results; } -} +} \ No newline at end of file diff --git a/edu_files/EduFiles/src/Order.java b/edu_files/EduFiles/src/Order.java deleted file mode 100644 index 242f322..0000000 --- a/edu_files/EduFiles/src/Order.java +++ /dev/null @@ -1,36 +0,0 @@ - -import java.io.Serializable; - -/* - * 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. - */ - -/** - * - * @author nag - */ -public class Order implements Serializable { - - private static final long serialVersionUID = -8358632374920029796L; - - String descr; - double price; - int unit; - boolean q; - - public Order(String descr, double price, int unit) { - this.descr = descr; - this.price = price; - this.unit = unit; - } - public Order(String descr, double price, int unit, String comment) { - this.descr = descr; - this.price = price; - this.unit = unit; - //this.comment = comment; - } - -} - diff --git a/edu_xml/eduxml/src/eduxml/EduXslt.java b/edu_xml/eduxml/src/eduxml/EduXslt.java index 5ec2dcb..b880984 100644 --- a/edu_xml/eduxml/src/eduxml/EduXslt.java +++ b/edu_xml/eduxml/src/eduxml/EduXslt.java @@ -10,6 +10,7 @@ import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; +import javax.swing.JOptionPane; import javax.xml.transform.Result; import javax.xml.transform.Source; import javax.xml.transform.Transformer; @@ -22,17 +23,23 @@ * @author nag */ public class EduXslt { - -public static void main(String[] args) throws Exception { - InputStream in = new FileInputStream("input.xml"); - OutputStream out = new FileOutputStream("output.xml"); - - Source xmlInput = new StreamSource(in); - Source xsl = new StreamSource(new File("transform.xsl")); - Result xmlOutput = new StreamResult(out); - - TransformerFactory tf = TransformerFactory.newInstance(); - Transformer transformer = tf.newTransformer(xsl); - transformer.transform(xmlInput, xmlOutput); -} + + public static void main(String[] args) throws Exception { + long startTime = 0; + long endTime = 0; + + InputStream in = new FileInputStream("src/input.xml"); + OutputStream out = new FileOutputStream("src/output.xml"); + + Source xmlInput = new StreamSource(in); + Source xsl = new StreamSource(new File("src/transform.xsl")); + Result xmlOutput = new StreamResult(out); + + TransformerFactory tf = TransformerFactory.newInstance(); + Transformer transformer = tf.newTransformer(xsl); + startTime = System.currentTimeMillis(); + transformer.transform(xmlInput, xmlOutput); + endTime = System.currentTimeMillis(); + JOptionPane.showMessageDialog(null, "Время преобразования xml файла: " + (endTime - startTime) / 1000.0 + " c"); + } }