亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? drawingfilereaderwriter.java

?? java的一些教程 大家看看,很有用的
?? JAVA
字號:
// DrawingFileReaderWriter.java
// DrawingFileReaderWriter defines static methods for reading
// and writing DeitelDrawing files on disk.
package com.deitel.advjhtp1.drawing;

// Java core packages
import java.io.*;
import java.util.*;
import java.awt.Color;

// Java extension packages
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;

// third-party packages
import org.w3c.dom.*;
import org.xml.sax.*;

// Deitel packages
import com.deitel.advjhtp1.drawing.model.*;
import com.deitel.advjhtp1.drawing.model.shapes.*;

public class DrawingFileReaderWriter {
   
   // write drawing to file with given fileName
   public static void writeFile( DrawingModel drawingModel, 
      String fileName ) 
   {
      // open file for writing and save drawing data
      try {
         
         DocumentBuilderFactory builderFactory =
            DocumentBuilderFactory.newInstance();
         
         DocumentBuilder builder = 
            builderFactory.newDocumentBuilder();
         
         Document document = builder.newDocument();
         
         // create shapes element to contain all MyShapes
         Element shapesElement = 
            document.createElement( "shapes" );
         document.appendChild( shapesElement );
         
         Iterator iterator = drawingModel.getShapes().iterator();
         
         // populate shapes element with shape element for each
         // MyShape in DrawingModel
         while ( iterator.hasNext() ) {
            MyShape shape = ( MyShape ) iterator.next();
            
            shapesElement.appendChild( shape.getXML( document ) );            
         }
         
         // use Transformer to write shapes XML document to a file
         TransformerFactory transformerFactory = 
            TransformerFactory.newInstance();
         
         Transformer transformer = 
            transformerFactory.newTransformer();
         
         // specify the shapes.dtd Document Type Definition
         transformer.setOutputProperty(
            OutputKeys.DOCTYPE_SYSTEM, "shapes.dtd" );
         
         transformer.transform( new DOMSource( document ), 
            new StreamResult( new FileOutputStream( 
               fileName ) ) );        
         
      } // end try
      
      // handle exception building XML Document
      catch ( ParserConfigurationException parserException ) {
         parserException.printStackTrace();
      }
      
      // handle exception transforming XML Document
      catch ( TransformerException transformerException ) {
         transformerException.printStackTrace();
      }
      
      // handle exception opening FileOutputStream
      catch( FileNotFoundException fileException ) { 
         fileException.printStackTrace(); 
      } 
      
   } // end method writeFile
   
   // open existing drawing from file
   public static Collection readFile( String fileName ) 
   {         
      // load shapes from file
      try {
         
         // Collection of MyShapes read from XML Document
         Collection shapes = new ArrayList();
         
         DocumentBuilderFactory builderFactory =
            DocumentBuilderFactory.newInstance();
         
         builderFactory.setValidating( true );
         
         DocumentBuilder builder = 
            builderFactory.newDocumentBuilder();
         
         Document document = builder.parse( 
            new File( fileName ) );
         
         // get all shape elements in XML Document
         NodeList list = document.getElementsByTagName( "shape" );
         
         // get MyShape from each shape element in XML Document
         for ( int i = 0; i < list.getLength(); i++ ) {            
            Element element = ( Element ) list.item( i );            
            MyShape shape = getShapeFromElement( element );            
            shapes.add( shape );            
         }
         
         return shapes;
         
      } // end try
      
      // handle exception parsing XML Document
      catch ( ParserConfigurationException parserException ) {
         parserException.printStackTrace();
      }     
      
      // handle exception parsing Document
      catch ( SAXException saxException ) {
         saxException.printStackTrace();
      }
      
      // handle exception reading Document from file
      catch ( IOException ioException ) {
         ioException.printStackTrace();
      }
         
      return null;
   
   } // end method readFile
   
   // create MyShape using properties specified in given Element
   private static MyShape getShapeFromElement( Element element )
   {
      MyShape shape = null;
      
      // get MyShape type (e.g., MyLine, MyRectangle, etc.)
      String type = element.getAttribute( "type" );
      
      // create appropriate MyShape subclass instance
      if ( type.equals( "MyLine" ) ) {
         shape = new MyLine();
      }
      
      else if ( type.equals( "MyRectangle" ) ) {
         shape = new MyRectangle();
      }
            
      else if ( type.equals( "MyOval" ) ) {
         shape = new MyOval();
      }
            
      else if ( type.equals( "MyText" ) ) {
         shape = new MyText();
         
         // create MyText reference for setting MyText-specific
         // properties, including fontSize, text, etc.
         MyText textShape  = ( MyText ) shape;
         
         // set text property
         String text = 
            getStringValueFromChildElement( element, "text" );
         
         textShape.setText( text );
         
         // set fontSize property
         int fontSize =
            getIntValueFromChildElement( element, "fontSize" );
         
         textShape.setFontSize( fontSize );
         
         // set fontName property
         String fontName =
            getStringValueFromChildElement( element, "fontName" );
         
         textShape.setFontName( fontName );
         
         // set underlined property
         boolean underlined = getBooleanValueFromChildElement( 
            element, "underlined" );
         
         textShape.setUnderlineSelected( underlined );
         
         // set bold property
         boolean bold =
            getBooleanValueFromChildElement( element, "bold" );
         
         textShape.setBoldSelected( bold );
         
         // set italic property
         boolean italic =
            getBooleanValueFromChildElement( element, "italic" );
         
         textShape.setItalicSelected( italic );  
      }
            
      else if ( type.equals( "MyImage" ) ) {
         shape = new MyImage();
         
         // create MyImage reference for setting MyImage-specific
         // fileName property
         MyImage imageShape = ( MyImage ) shape;
         
         String fileName = getStringValueFromChildElement(
            element, "fileName" );
         
         imageShape.setFileName( fileName );
      }
      
      // set properties common to all MyShapes, including x1, y1,
      // x2, y2, startColor, endColor, etc.
      
      // set x1 and y1 properties
      int x1 = getIntValueFromChildElement( element, "x1" );
      int y1 = getIntValueFromChildElement( element, "y1" );
      
      shape.setPoint1( x1, y1 );
      
      // set x2 and y2 properties
      int x2 = getIntValueFromChildElement( element, "x2" );
      int y2 = getIntValueFromChildElement( element, "y2" );
      
      shape.setPoint2( x2, y2 );
      
      // set startX and startY properties
      int startX = 
         getIntValueFromChildElement( element, "startX" );
      int startY = 
         getIntValueFromChildElement( element, "startY" );
      
      shape.setStartPoint( startX, startY );
      
      // set endX and endY properties
      int endX = getIntValueFromChildElement( element, "endX" );
      int endY = getIntValueFromChildElement( element, "endY" );
      
      shape.setEndPoint( endX, endY );
      
      // set startColor and endColor properties
      Color startColor = 
         getColorValueFromChildElement( element, "startColor" );
      
      shape.setStartColor( startColor );

      Color endColor = 
         getColorValueFromChildElement( element, "endColor" );   
      
      shape.setEndColor( endColor );
      
      // set useGradient property
      boolean useGradient = getBooleanValueFromChildElement( 
         element, "useGradient" );
      
      shape.setUseGradient( useGradient );
      
      // set strokeSize property
      float strokeSize = getFloatValueFromChildElement(
         element, "strokeSize" );
      
      shape.setStrokeSize( strokeSize );
      
      // set filled property
      boolean fill = 
         getBooleanValueFromChildElement( element, "fill" );
      
      shape.setFilled( fill );
      
      return shape;
      
   } // end method getShapeFromElement
   
   // get int value from child element with given name
   private static int getIntValueFromChildElement( Element parent,
      String childElementName )
   {
      // get NodeList for Elements of given childElementName
      NodeList childNodes = parent.getElementsByTagName(
         childElementName );
      
      // get Text Node from zeroth child Element
      Node childTextNode = childNodes.item( 0 ).getFirstChild();
      
      // parse int value from Text Node
      return Integer.parseInt( childTextNode.getNodeValue() ); 
      
   } // end method getIntValueFromChildElement
   
   // get float value from child element with given name
   private static float getFloatValueFromChildElement(
      Element parent, String childElementName )
   {
      // get NodeList for Elements of given childElementName
      NodeList childNodes = parent.getElementsByTagName(
         childElementName );
      
      // get Text Node from zeroth child Element
      Node childTextNode = childNodes.item( 0 ).getFirstChild();
      
      // parse float value from Text Node
      return Float.parseFloat( childTextNode.getNodeValue() );  
      
   } // end method getFloatValueFromChildElement
   
   // get boolean value from child element with given name
   private static boolean getBooleanValueFromChildElement(
      Element parent, String childElementName )
   {
      // get NodeList for Elements of given childElementName
      NodeList childNodes = parent.getElementsByTagName(
         childElementName );
      
      Node childTextNode = childNodes.item( 0 ).getFirstChild();
      
      // parse boolean value from Text Node
      return Boolean.valueOf( 
         childTextNode.getNodeValue() ).booleanValue();   
      
   } // end method getBooleanValueFromChildElement
   
   // get String value from child element with given name
   private static String getStringValueFromChildElement(
      Element parent, String childElementName )
   {
      // get NodeList for Elements of given childElementName
      NodeList childNodes = parent.getElementsByTagName(
         childElementName );
      
      // get Text Node from zeroth child Element
      Node childTextNode = childNodes.item( 0 ).getFirstChild();
      
      // return String value of Text Node
      return childTextNode.getNodeValue();  
      
   }  // end method getStringValueFromChildElement 
   
   // get Color value from child element with given name
   private static Color getColorValueFromChildElement(
      Element parent, String childElementName )
   {
      // get NodeList for Elements of given childElementName
      NodeList childNodes = parent.getElementsByTagName(
         childElementName );
      
      // get zeroth child Element
      Element childElement = ( Element ) childNodes.item( 0 );
      
      // get red, green and blue attribute values
      int red = Integer.parseInt( 
         childElement.getAttribute( "red" ) );
      
      int green = Integer.parseInt( 
         childElement.getAttribute( "green" ) );
      
      int blue = Integer.parseInt( 
         childElement.getAttribute( "blue" ) );      
      
      // return Color for given red, green and blue values
      return new Color( red, green, blue );           
      
   } // end method getColorValueFromChildElement
}

/***************************************************************
 * (C) Copyright 2002 by Deitel & Associates, Inc. and         *
 * Prentice Hall. All Rights Reserved.                         *
 *                                                             *
 * DISCLAIMER: The authors and publisher of this book have     *
 * used their best efforts in preparing the book. These        *
 * efforts include the development, research, and testing of   *
 * the theories and programs to determine their effectiveness. *
 * The authors and publisher make no warranty of any kind,     *
 * expressed or implied, with regard to these programs or to   *
 * the documentation contained in these books. The authors     *
 * and publisher shall not be liable in any event for          *
 * incidental or consequential damages in connection with, or  *
 * arising out of, the furnishing, performance, or use of      *
 * these programs.                                             *
 ***************************************************************/

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品美女在线播放| 天天亚洲美女在线视频| √…a在线天堂一区| 日韩专区在线视频| a4yy欧美一区二区三区| 91精品在线免费| 亚洲欧美乱综合| 国产精品538一区二区在线| 欧美在线观看禁18| 国产精品无遮挡| 精品一区二区三区视频| 欧美伊人久久久久久午夜久久久久| 精品日产卡一卡二卡麻豆| 亚洲综合av网| 99re8在线精品视频免费播放| 亚洲激情综合网| 国产精品1024| 精品99久久久久久| 日韩高清不卡一区二区三区| 色94色欧美sute亚洲13| 国产精品久久久久一区二区三区| 久草在线在线精品观看| 91精品国产麻豆| 天堂久久一区二区三区| 欧美日韩精品一区视频| 亚洲综合免费观看高清完整版| www.综合网.com| 中文字幕巨乱亚洲| 国产美女视频91| 久久青草欧美一区二区三区| 美腿丝袜亚洲一区| 欧美一级黄色片| 免费高清在线一区| 日韩色视频在线观看| 日韩影院免费视频| 91精品国产入口| 蜜桃免费网站一区二区三区| 欧美一卡在线观看| 另类成人小视频在线| 欧美大片在线观看一区二区| 蜜桃视频一区二区三区 | 亚洲一区二区三区激情| 91视频www| 亚洲一级二级在线| 欧美男生操女生| 美女网站在线免费欧美精品| 欧美欧美欧美欧美| 另类小说欧美激情| 国产日韩欧美精品电影三级在线| 国产不卡视频一区二区三区| 亚洲国产电影在线观看| 91免费看视频| 日本一区中文字幕| 久久久久久久久久美女| 波多野结衣精品在线| 亚洲精品视频免费观看| 欧美日韩一区小说| 黄色日韩三级电影| 亚洲视频在线一区观看| 欧美日本高清视频在线观看| 国内精品嫩模私拍在线| 国产精品传媒视频| 欧美视频中文字幕| 奇米在线7777在线精品| 国产精品国产成人国产三级 | 蜜臀国产一区二区三区在线播放 | av欧美精品.com| 一区二区三区四区精品在线视频| 欧美一区二区在线播放| 国产成人精品影视| 亚洲第一电影网| 欧美国产日韩在线观看| 欧美亚日韩国产aⅴ精品中极品| 久久国产乱子精品免费女| 中文字幕视频一区| 日韩一区二区在线观看| 99久久99久久精品免费看蜜桃| 亚洲第一在线综合网站| 国产欧美精品在线观看| 欧美精品免费视频| 成人免费三级在线| 午夜精品成人在线| 最新国产の精品合集bt伙计| 日韩精品一区二区三区swag| 色综合中文字幕国产| 奇米影视一区二区三区小说| 亚洲天堂精品在线观看| 精品国产电影一区二区| 欧美性淫爽ww久久久久无| 福利电影一区二区| 久久狠狠亚洲综合| 一区二区三区毛片| 国产精品久久久久国产精品日日| 91精品国产欧美日韩| 在线免费精品视频| 成人app在线观看| 国产美女娇喘av呻吟久久| 亚洲va国产va欧美va观看| 亚洲天堂中文字幕| 国产精品女同互慰在线看| 精品日产卡一卡二卡麻豆| 91精品国模一区二区三区| 色婷婷综合久久久| 99久久伊人精品| 成人一区二区在线观看| 国产成人午夜高潮毛片| 韩国女主播一区| 国产在线不卡一卡二卡三卡四卡| 日韩精彩视频在线观看| 日韩在线a电影| 天堂精品中文字幕在线| 午夜激情久久久| 天天色天天操综合| 丝袜诱惑亚洲看片| 图片区小说区区亚洲影院| 亚洲成人你懂的| 天天做天天摸天天爽国产一区 | 秋霞电影网一区二区| 亚洲成人免费观看| 午夜av电影一区| 蜜臀91精品一区二区三区| 男人的j进女人的j一区| 久久国产剧场电影| 777欧美精品| 717成人午夜免费福利电影| 欧美军同video69gay| 欧美一区二区三区白人| 欧美va亚洲va香蕉在线| 精品国产免费人成在线观看| 久久久99精品久久| 欧美韩国日本一区| 亚洲免费成人av| 亚洲第一主播视频| 久久国产精品72免费观看| 精品一区二区三区免费毛片爱| 国产精品中文字幕欧美| av高清久久久| 欧美日韩久久一区| 日韩精品中文字幕在线一区| 久久免费看少妇高潮| 日韩理论片一区二区| 午夜日韩在线电影| 国产米奇在线777精品观看| www.亚洲人| 欧美放荡的少妇| 国产亚洲精品免费| 一区二区三区四区中文字幕| 美女网站在线免费欧美精品| 东方aⅴ免费观看久久av| 欧美在线影院一区二区| 日韩精品一区二区三区中文不卡| 久久精品亚洲麻豆av一区二区| 亚洲欧美日韩国产手机在线| 日韩电影在线一区| www.欧美.com| 欧美一区二区三区白人| 最新国产成人在线观看| 日本中文字幕一区二区有限公司| 粉嫩aⅴ一区二区三区四区| 在线视频一区二区三| 欧美一区二区免费观在线| 国产精品你懂的| 久久99精品久久久久久动态图| 97精品电影院| 久久综合五月天婷婷伊人| 日韩理论片一区二区| 国产一区不卡在线| 555夜色666亚洲国产免| 国产精品二三区| 国产一区二区91| 欧美一区二区三区在线| 亚洲精品乱码久久久久久日本蜜臀| 久久疯狂做爰流白浆xx| 欧美在线制服丝袜| 亚洲欧洲成人精品av97| 国产伦精品一区二区三区免费迷| 欧美久久久久中文字幕| 亚洲欧美视频在线观看| 粉嫩久久99精品久久久久久夜| 91精品一区二区三区久久久久久| 一区二区三区四区高清精品免费观看 | 婷婷中文字幕综合| 91丨九色丨蝌蚪富婆spa| 国产亚洲精品7777| 久久电影网站中文字幕| 欧美高清视频一二三区 | 国产精品一区二区男女羞羞无遮挡| 欧美视频在线不卡| 亚洲欧美怡红院| 成人动漫在线一区| 久久美女高清视频| 激情文学综合网| 精品国产乱码久久久久久图片 | 国产精品小仙女| 欧美精品一区二区三区蜜桃| 美女视频黄久久| 欧美成人激情免费网| 裸体健美xxxx欧美裸体表演| 666欧美在线视频| 蜜乳av一区二区|