XML과 E4X 다루기
Ulysses Ulysses Joyce, James Myung jin, Hwang Penguin Books Ltd A very thick book
자식 노드 접근하기
novel.children();
novel.*
//첫번째 자식노드에 접근하기
novel.*[0];
novel.children()[0];
//마지막 자식노드에 접근하기
novel.children()[novel.children().length() - 1];
//이름이 SUBJECT인 root의 모든 자식 엘리번트 반환
novel.child("SUBJECT");
novel.SUBJECT ;
//이름이 SUBJECT인 ROOT의 모든 자식 엘리먼트의 첫번째 SUBJECT 요소
novel.child("SUBJECT")[0];
novel.SUBJECT[0];
//이름이 AUTHOR의 첫번째 엘리먼트의 이름을 WRITER로 변경한다.
novel.AUTHOR[0].setName("WRITER");
텍스트 노드에 접근하기
novel.SUBJECT.children()[0];
novel.SUBJECT.*[0]
//<SUBJECT> 엘리먼트의 대한 참조
novel.SUBJECT.*[0].parent();
//문자열 "text" 반환
novel.SUBJECT.*[0].nodeKind();
//문자열 "Ulysses" 반환
novel.SUBJECT.*[0].toString();
novel.SUBJECT.*[0] //암시적으로 toString()로 변환해준다.
novel.SUBJECT //Subject가 하나일 경우 텍스트 노드를 문자열로 반환한다.
//텍스트 엘리먼트 가져오기
novel.DESCRIPTION.text() --> A, thick book
novel.DESCRIPTION.text()[0] --> A
novel.DESCRIPTION.text()[1] --> thick book
부모 노드 접근하기
<grandparent>
<parent>
<child></child>
</parent>
</grandparent>;
var kid:XML = doc.parent.child[0];
var parent:XML = kid.parent();
var grandparent:XML = kid.parent().parent();
trace(parent);
trace(grandparent);
형제 노드 접근하기
//이전 형제 노드
trace(author.parent().*[author.childIndex()-1]);
//다음 형제 노드
trace(author.parent().*[author.childIndex()+1]);
어트리뷰트 접근하기
주석과 처리 지시문 접근하기
'개발 > FLEX & AIR' 카테고리의 다른 글
Flex 컴포넌트의 비율 유지 (0) | 2009.12.21 |
---|---|
Flex와 Java간 소켓 통신 (1) | 2009.12.21 |
[Flex] PieChart (0) | 2009.11.24 |
[Flex] LineChart (0) | 2009.11.24 |
[Chart] ColumnChart, BarChart (0) | 2009.11.24 |
[java] Properties 읽고 쓰기
java.util.Properties 파일 사용 예제
package kr.pe.anaconda.test.io.file; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Map; import java.util.Properties; /** * @author diem * */ public class PropertiesSample { private static String defaultPropertiesPath = "c:\\example.properties"; public static String getDefaultPropertiesPath() { return defaultPropertiesPath; } public static void setDefaultPropertiesPath(String defaultPropertiesPath) { PropertiesSample.defaultPropertiesPath = defaultPropertiesPath; } public static String getKey(String key) throws Exception { // ClassLoader.getResourceAsStream("some/pkg/resource.properties"); // Class.getResourceAsStream("/some/pkg/resource.properties"); // ResourceBundle.getBundle("some.pkg.resource"); String value = null; InputStream is = new FileInputStream(defaultPropertiesPath); Properties p = null; try { p = new Properties(); p.load(is); value = p.getProperty(key); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try {is.close();} catch (IOException e) {} } return value; } /** * 프로퍼티 파일에 사용자 값을 넣는다. */ public static void putPropertie(MapparamMap) throws FileNotFoundException, IOException { // 프로퍼티 파일 경로 key String propertiesKey = "properties.file.path"; Properties proper = null; FileOutputStream output = null; try { String comment = paramMap.get("properties.comment"); // 사용자가 프로퍼티 파일 경로를 넘기지 않을 경우 default properties로 셋팅하다. if (!paramMap.containsKey(propertiesKey)) { paramMap.put(propertiesKey, defaultPropertiesPath); } output = new FileOutputStream(paramMap.get(propertiesKey)); // paramMap.remove(propertiesKey); proper = new Properties(); proper.putAll(paramMap); proper.store(output, comment); } catch (FileNotFoundException fnfe) { throw new FileNotFoundException("properties 파일을 찾을수 없습니다."); } catch (IOException ioe) { throw new IOException("putPropertie Exception!", ioe); } finally { try { output.close(); } catch (IOException e) { } } } /** * @param args */ public static void main(String[] args) throws Exception { // TODO Auto-generated method stub Map paramMap = new HashMap (); paramMap.put("properties.file.path", "c:\\example12.properties"); paramMap.put("name", "홍길동"); paramMap.put("age", "31"); paramMap.put("phone", "0111234567"); PropertiesSample.putPropertie(paramMap); PropertiesSample.setDefaultPropertiesPath(paramMap .get("properties.file.path")); System.out.println(PropertiesSample.getDefaultPropertiesPath()); System.out.println(PropertiesSample.getKey("name")); } }
'개발 > Java' 카테고리의 다른 글
Spring - Java/J2EE Application FrameworkVersion 1.2.2 (0) | 2010.02.04 |
---|---|
Tip. MessageFormat 예제 (0) | 2010.01.07 |
[java] ResourceBundle 예제 (0) | 2009.12.04 |
[Java] File 클래스 속성 및 사용법 (0) | 2009.11.29 |
[Java] 파일에 텍스트 이어서 쓰기 (0) | 2009.11.25 |
[java] ResourceBundle 예제
날씨가 조금 추워지네요..
요즘 아이폰 만지는 재미에 아침이 밝아 오는지도 모르고 유용한 어플을 찾아서 헤매고 있습니다. 이제 좀 정신좀 차려야 되는데 말이죠.. ㅜㅜ
간단하게 ResourceBundle을 사용하는 법을 올려봅니다.
좀 더 사용하기 쉽게 만들수도 있겠지만 그건 개인에 따라서 수정하면 될테고 어떻게 사용되는지만 알면 수정은 쉬우니까요^^
package pe.kr.anaconda.hmjkor.util; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; import java.util.ResourceBundle; /** * @author diem * */ public class ResourceUtil { /* * url.properties * url = http://hmjkor.tistory.com */ private static final String CONF_PATH = "config.url"; private static ResourceBundle resource = ResourceBundle.getBundle(CONF_PATH); private static HashMapsourceMap = new HashMap (); static{ Enumeration enu = resource.getKeys(); String key = null; while(enu.hasMoreElements()){ key = enu.nextElement(); sourceMap.put(key, resource.getString(key)); } } public static String getKey(String key){ return sourceMap.get(key); } public static Map getSourceMap(){ return sourceMap; } public static void main(String args){ System.out.println(ResourceUtil.getKey("url")); } }
'개발 > Java' 카테고리의 다른 글
Tip. MessageFormat 예제 (0) | 2010.01.07 |
---|---|
[java] Properties 읽고 쓰기 (0) | 2009.12.04 |
[Java] File 클래스 속성 및 사용법 (0) | 2009.11.29 |
[Java] 파일에 텍스트 이어서 쓰기 (0) | 2009.11.25 |
[Spring] dbcp와 c3p0 커넥션 풀 유지하기 (0) | 2009.11.25 |
[Java] File 클래스 속성 및 사용법
1. File 클래스 및 속성
package kr.pe.anaconda.test.io.file; import java.io.File; import java.io.IOException; /** * File 클래스 사용법 및 속성 * @author diem * */ public class FileEx1 { /** * @param args */ public static void main(String[] args) throws IOException { // TODO Auto-generated method stub File f = new File("c:\\logs\\123.txt"); String fileName = f.getName(); int pos = fileName.lastIndexOf("."); System.out.println("경로를 제외한 파일 이름 : " + f.getName()); System.out.println("확장자를 제외한 파일 이름 : " + fileName.substring(0, pos)); System.out.println("확장자 : " + fileName.substring(pos + 1)); System.out.println("경로를 포함한 파일이름 : " + f.getPath()); System.out.println("파일의 절대경로 : " + f.getAbsolutePath()); System.out.println("파일이 속해 있는 경로 : " + f.getParent()); System.out.println(); System.out.println("File.pathSeparator : " + File.pathSeparator); System.out.println("File.pathSeparatorChar : " + File.pathSeparatorChar); System.out.println("File.separator : " + File.separator); System.out.println("File.separatorChar : " + File.separatorChar); System.out.println(); System.out.println("user.dir : " + System.getProperty("user.dir")); System.out.println("sun.boot.class.path : " + System.getProperty("sun.boot.class.path")); } }
2. 파일 리스트
package kr.pe.anaconda.test.io.file; import java.io.File; /** * 디렉터리 리스트 * @author diem * */ public class FileEx2 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub if(args.length != 1){ System.out.println("USAGE : java FileEx2 DIRECTORY"); System.exit(0); } File f = new File("c:\\log"); //File f = new File(args[0]); if(!f.exists() || !f.isDirectory()){ System.out.println("유효하지 않은 디렉토리입니다."); System.exit(0); } File[] files = f.listFiles(); for(int i = 0; i < files.length; i++){ String fileName = files[i].getName(); System.out.println(files[i].isDirectory() ? "["+ fileName +"]" : fileName); } } }
3. 파일 디렉터리의 파일 갯수와 디렉터리 숫자 보여주기
package kr.pe.anaconda.test.io.file; import java.io.File; import java.util.ArrayList; /** * 특정 디렉터리의 파일의 갯수와 디렉터리의 숫자를 보여준다. * @author diem * */ public class FileEx3 { static int totalFiles = 0; static int totalDirs = 0; /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub if(args == null || args.length == 0){ args = new String[1]; } System.out.println(args.length); args[0] = "c:\\logs"; if(args.length != 1){ System.out.println("USAGE : java FileEx3 DIRECTORY"); System.exit(0); } File dir = new File(args[0]); if(!dir.exists() || !dir.isDirectory()){ System.out.println("유효하지 않은 디렉토리입니다."); System.exit(0); } printFileList(dir); System.out.println(); System.out.println("총 " + totalFiles + "개의 파일"); System.out.println("총 " + totalDirs + "개의 디렉터리"); } public static void printFileList(File dir) { System.out.println(dir.getAbsolutePath() + " 디렉터리"); File[] files = dir.listFiles(); ArrayList subDir = new ArrayList(); for(int i = 0; i < files.length; i++){ String fileName = files[i].getName(); if(files[i].isDirectory()){ fileName = "["+ fileName +"]"; subDir.add(i+""); } System.out.println(fileName); } int dirNum = subDir.size(); int fileNum = files.length - dirNum; totalFiles += fileNum; totalDirs += dirNum; System.out.println(fileNum + "개의 파일, " + dirNum + "개의 디렉터리"); System.out.println(); for(int i = 0; i < subDir.size(); i++){ int index = Integer.parseInt((String)subDir.get(i)); printFileList(files[index]); } } }
4. 파일 리스트를 출력
package kr.pe.anaconda.test.io.file; import java.io.File; import java.text.SimpleDateFormat; /** * 파일 리스트를 출력한다. * 출력시 파일의 속성과 수정일을 함께 출력한다. * @author diem * */ public class FileEx4 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub String currDir = System.getProperty("user.dir"); File dir = new File(currDir); File[] files = dir.listFiles(); for(int i = 0; i < files.length; i++){ File f = files[i]; String name = f.getName(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mma"); String attribute = ""; String size = ""; if(files[i].isDirectory()){ attribute = "DIR"; }else{ size = f.length() + ""; attribute = f.canRead() ? "R" : ""; attribute += f.canWrite() ? "W" : ""; attribute += f.isHidden() ? "H" : ""; } System.out.printf("%s %3s %6s %s\n", df.format(f.lastModified()), attribute, size, name); } } }
5. 파일 정렬
package kr.pe.anaconda.test.io.file; import java.io.File; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Comparator; /** * 파일 정렬을 한다. * @author diem * */ public class FileEx5 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub if (args.length != 1 || args[0].length() != 1 || "tTlLnN".indexOf(args[0]) == -1) { System.out.println("USAGE : java FileEx5 SORT_OPTION "); System.out.println(" SORT_OPTION : "); System.out.println(" t Time asending sort. "); System.out.println(" T Time descending sort. "); System.out.println(" l Length ascending sort. "); System.out.println(" L Length descending sort. "); System.out.println(" n Name asending sort. "); System.out.println(" N Name descending sort. "); } final char option = args[0].charAt(0); String currDir = System.getProperty("user.dir"); File dir = new File(currDir); File[] files = dir.listFiles(); Comparator comp = new Comparator() { public int compare(Object o1, Object o2) { long time1 = ((File) o1).lastModified(); long time2 = ((File) o2).lastModified(); long length1 = ((File) o1).length(); long length2 = ((File) o2).length(); String name1 = ((File) o1).getName().toLowerCase(); String name2 = ((File) o2).getName().toLowerCase(); int result = 0; switch (option) { case 't': if (time1 - time2 > 0) result = 1; else if (time1 - time2 == 0) result = 0; else if (time1 - time2 < 0) result = -1; break; case 'T': if (time1 - time2 > 0) result = -1; else if (time1 - time2 == 0) result = 0; else if (time1 - time2 < 0) result = 1; break; case 'l': if (length1 - length2 > 0) result = -1; else if (length1 - length2 == 0) result = 0; else if (length1 - length2 < 0) result = 1; break; case 'L': if (length1 - length2 > 0) result = 1; else if (length1 - length2 == 0) result = 0; else if (length1 - length2 < 0) result = -1; break; case 'n': result = name1.compareTo(name2); break; case 'N': result = name2.compareTo(name1); break; } return result; } public boolean equals(Object o) { return false; } }; Arrays.sort(files, comp); for (int i = 0; i < files.length; i++) { File f = files[i]; String name = f.getName(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mma"); String attribute = ""; String size = ""; if (files[i].isDirectory()) { attribute = "DIR"; } else { size = f.length() + ""; attribute = f.canRead() ? "R" : ""; attribute += f.canWrite() ? "W" : ""; attribute += f.isHidden() ? "H" : ""; } System.out.printf("%s %3s %6s %s\n", df.format(f.lastModified()), attribute, size, name); } } }
6. 특정 확장자를 가진 파일 출력
package kr.pe.anaconda.test.io.file; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; /** * 특정 확장자를 가진 파일을 출력한다. * @author diem * */ public class FileEx6 { static int found = 0; /** * @param args */ public static void main(String[] args) { if (args.length != 2) { System.out.println("USAGE : java FileEx6 DIRECTORY KEYWORD"); System.exit(0); } File dir = new File(args[0]); String keyword = args[1]; if (!dir.exists() || !dir.isDirectory()) { System.out.println("유효하지 않은 디렉터리 입니다."); System.exit(0); } try { findInFiles(dir, keyword); } catch (IOException e) { e.printStackTrace(); } } public static void findInFiles(File dir, String keyword) throws IOException { // TODO Auto-generated method stub File[] files = dir.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { findInFiles(files[i], keyword); } else { //파일이름 String filename = files[i].getName(); //파일 확장자 String extension = filename .substring(filename.lastIndexOf(".") + 1); extension = "," + extension + ","; if(",java,txt,bak,".indexOf(extension) == -1) continue; filename = dir.getAbsolutePath() + File.separator + filename; FileReader fr = new FileReader(files[i]); BufferedReader br = new BufferedReader(fr); String data = ""; int lineNum = 0; while((data = br.readLine()) != null){ lineNum++; if(data.indexOf(keyword) != -1){ found++; System.out.println("["+filename+"("+lineNum+") ]" + data); } } br.close(); } } } }
7. 특정한 이름을 포함한 파일의 목록을 출력
package kr.pe.anaconda.test.io.file; import java.io.File; import java.io.FilenameFilter; /** * 특정한 이름을 포함한 파일의 목록을 보여준다. * @author diem * */ public class FileEx7 { /** * @param args */ public static void main(String[] args) { if (args.length != 1) { System.out.println("USAGE : java FileEx7 pattern"); System.exit(0); } String currDir = System.getProperty("user.dir"); //currDir = "c:\\logs"; File dir = new File(currDir); final String pattern = args[0]; //String[] list = (FilenameFilter filter) String[] files = dir.list(new FilenameFilter() { @Override public boolean accept(File dir, String name) { // TODO Auto-generated method stub return name.indexOf(pattern) != -1; } }); for(int i = 0; i < files.length; i++){ System.out.println(files[i]); } } }
8. 지정된 디렉터리에 정의한 확장자를 가진 파일을 삭제
package kr.pe.anaconda.test.io.file; import java.io.File; import java.io.FilenameFilter; /** * 지정된 디렉터리에 정의한 확장자를 가진 파일을 삭제한다. * @author diem * */ public class FileEx8 { static int deleteFiles = 0; /** * @param args */ public static void main(String[] args) { if (args.length != 1) { System.out.println("USAGE : java FileEx8 Extension"); System.exit(0); } String currDir = System.getProperty("user.dir"); currDir = "c:\\logs"; File dir = new File(currDir); //final String ext = "." + args[0]; final String ext = ".bak"; delete(dir, ext); System.out.println(deleteFiles + " 개의 파일이 삭제 되었습니다."); } private static void delete(File dir, String ext) { // TODO Auto-generated method stub File[] files = dir.listFiles(); for(int i = 0; i < files.length; i++){ if(files[i].isDirectory()){ delete(files[i], ext); }else{ String filename = files[i].getAbsolutePath(); if(filename.endsWith(ext)){ System.out.print(filename); if(files[i].delete()){ System.out.println("-삭제 성공"); deleteFiles++; }else{ System.out.println("-삭제 실패"); } } } } } }
9. 지정된 디렉터리에 파일명이 숫자인 경우 파일명을 변경
package kr.pe.anaconda.test.io.file; import java.io.File; /** * 지정된 디렉터리에 파일명이 숫자인 경우 파일명을 변경한다. * ex) 1.gif -> 00001.gif * @author diem * */ public class FileEx9 { /** * @param args */ public static void main(String[] args) { if (args.length != 0) { System.out.println("USAGE : java FileEx9 DIRECTORY"); System.exit(0); } //File dir = new File(args[0]); File dir = new File("c:\\logs"); if(!dir.exists() || !dir.isDirectory()){ System.out.println("유효하지 않은 디렉토리입니다."); System.exit(0); } File[] files = dir.listFiles(); for(int i = 0; i < files.length; i++){ String fileName = files[i].getName(); //파일명 System.out.println("파일이름 :" + fileName); String newFileName = "0000" + fileName; newFileName = newFileName.substring(newFileName.length() - 7); System.out.println("변경된 파일 이름 : " + newFileName ); files[i].renameTo(new File(dir, newFileName)); } } }
'개발 > Java' 카테고리의 다른 글
[java] Properties 읽고 쓰기 (0) | 2009.12.04 |
---|---|
[java] ResourceBundle 예제 (0) | 2009.12.04 |
[Java] 파일에 텍스트 이어서 쓰기 (0) | 2009.11.25 |
[Spring] dbcp와 c3p0 커넥션 풀 유지하기 (0) | 2009.11.25 |
[java] 저장소 정보 확인 (0) | 2009.11.24 |
[Java] 파일에 텍스트 이어서 쓰기
java에서 파일에 추가 라인을 입력하고 싶을때 옵션입니다. 15라인 참고하면 됩니다.
- package kr.pe.anaconda.test;
- import java.io.FileNotFoundException;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.io.PrintWriter;
- public class Test {
- String file = "C:/logs/log.log";
- PrintWriter pw = null;
- try {
- pw.write("\n");
- e.printStackTrace();
- e.printStackTrace();
- }finally{
- if(pw != null) pw.close();
- }
- }
- }
'개발 > Java' 카테고리의 다른 글
[java] ResourceBundle 예제 (0) | 2009.12.04 |
---|---|
[Java] File 클래스 속성 및 사용법 (0) | 2009.11.29 |
[Spring] dbcp와 c3p0 커넥션 풀 유지하기 (0) | 2009.11.25 |
[java] 저장소 정보 확인 (0) | 2009.11.24 |
자주 쓰는 Maven 설정 정리 (0) | 2009.11.16 |
[Spring] dbcp와 c3p0 커넥션 풀 유지하기
JDBC 커넥션 풀을 지원하는 대표적인 오픈소스 중에 아파치 DBCP와 C3P0가 있다. 이들은 Spring, Hibernate 등과 통합되어 DB 커넥션 풀을 제공하는 DataSource를 구성하여 자주 쓰인다.
오라클이나 MySQL 등 DBMS들은 기본적으로 특정 시간동안 실행이 없으면 해당 세션을 종료하게 된다. 이렇게 종료된 커넥션은 어플리케이션에서 오류를 발생시키게 되므로 커넥션을 유지하기 위한 별도 설정을 필요로 하게 된다. 커넥션을 얻어올 때 커넥션 테스트를 수행하고 실패하면 새로운 커넥션을 생성할 수 있다. 또한 idle 타임에 주기적으로 커넥션 테스트를 수행할 수도 있다.
아래는 dbcp를 이용하여 구성한 스프링 DataSource 설정의 예이다.
|
아래는 c3p0를 이용하여 구성한 스프링 DataSource 설정의 예이다.
|
참조:
- DBCP Configuration: http://commons.apache.org/dbcp/configuration.html
- C3P0 Configuraion: http://www.mchange.com/projects/c3p0/index.html
출처 : http://www.java2go.net/blog/117
'개발 > Java' 카테고리의 다른 글
[Java] File 클래스 속성 및 사용법 (0) | 2009.11.29 |
---|---|
[Java] 파일에 텍스트 이어서 쓰기 (0) | 2009.11.25 |
[java] 저장소 정보 확인 (0) | 2009.11.24 |
자주 쓰는 Maven 설정 정리 (0) | 2009.11.16 |
[ibatis]동적 컬럼 생성시 컬럼정보를 제대로 가져오지 못하는 현상 (1) | 2009.11.12 |
[Flex] PieChart
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
private var medalsAC:ArrayCollection = new ArrayCollection( [
{ Country: "USA", Gold: 35, Silver:39, Bronze: 29 },
{ Country: "China", Gold: 32, Silver:17, Bronze: 14 },
{ Country: "Korea", Gold: 5, Silver:57, Bronze: 4 },
{ Country: "Russia", Gold: 27, Silver:27, Bronze: 38 } ]);
private function displayGold(data:Object, field:String, index:Number, percentValue:Number):String {
var temp:String= (" " + percentValue).substr(0,6);
return data.Country + ": " + '\n' + "Total Gold: " + data.Gold + '\n' + temp + "%";
}
]]>
</mx:Script>
<mx:SolidColor id="sc1" color="blue" alpha=".6"/>
<mx:SolidColor id="sc2" color="red" alpha=".6"/>
<mx:SolidColor id="sc3" color="0x663300" alpha=".6"/>
<mx:SolidColor id="sc4" color="yellow" alpha=".6"/>
<mx:Stroke id="callouts" weight="2" color="0x999999" alpha=".8" caps="square"/>
<!-- This Stroke is used to separate the wedges in the pie. -->
<mx:Stroke id="radial" weight="1" color="0xFFFFCC" alpha=".3"/>
<mx:Stroke id="pieborder" color="0x000000" weight="2" alpha=".5"/>
<mx:PieChart id="chart1"
height="100%"
width="100%"
paddingRight="5"
paddingLeft="5"
showDataTips="true"
dataProvider="{medalsAC}"
>
<!-- -->
<mx:series>
<mx:PieSeries
nameField="Country"
labelPosition="callout"
field="Gold"
labelFunction="displayGold"
calloutStroke="{callouts}"
radialStroke="{radial}"
stroke="{pieborder}"
fills="{[sc1, sc2, sc3, sc4]}"
>
<!-- Clear the drop shadow filters from the chart. -->
<mx:filters>
<mx:Array/>
</mx:filters>
</mx:PieSeries>
</mx:series>
</mx:PieChart>
<mx:Legend dataProvider="{chart1}"/>
</mx:Panel>
</mx:Application>
'개발 > FLEX & AIR' 카테고리의 다른 글
Flex와 Java간 소켓 통신 (1) | 2009.12.21 |
---|---|
XML과 E4X 다루기 (0) | 2009.12.20 |
[Flex] LineChart (0) | 2009.11.24 |
[Chart] ColumnChart, BarChart (0) | 2009.11.24 |
[FLEX] HTTPService를 사용하여 파라미터 전송하기 (0) | 2009.10.25 |
[Flex] LineChart
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
public var stockDataAC:ArrayCollection = new ArrayCollection( [
{date: "2005, 7, 27", close: 41.71},
{date: "2005, 7, 28", close: 42.21},
{date: "2005, 7, 29", close: 42.11},
{date: "2005, 8, 1", close: 42.71},
{date: "2005, 8, 2", close: 42.99},
{date: "2005, 8, 3", close: 44} ]);
public function myParseFunction(s:String):Date {
// Get an array of Strings from the comma-separated String passed in.
var a:Array = s.split(",");
// Create the new Date object. Subtract one from
// the month property because months are zero-based in
// the Date constructor.
var newDate:Date = new Date(a[0],a[1]-1,a[2]);
return newDate;
}
]]>
</mx:Script>
<mx:LineChart id="mychart" height="500" width="450"
paddingRight="5" paddingLeft="5"
showDataTips="true" dataProvider="{stockDataAC}">
<mx:horizontalAxis>
<mx:DateTimeAxis dataUnits="days" parseFunction="myParseFunction"/>
</mx:horizontalAxis>
<mx:LinearAxis baseAtZero="false" />
</mx:verticalAxis>
<mx:LineSeries yField="close" xField="date" displayName="AAPL"/>
</mx:series>
</mx:LineChart>
</mx:Panel>
</mx:Application>
'개발 > FLEX & AIR' 카테고리의 다른 글
XML과 E4X 다루기 (0) | 2009.12.20 |
---|---|
[Flex] PieChart (0) | 2009.11.24 |
[Chart] ColumnChart, BarChart (0) | 2009.11.24 |
[FLEX] HTTPService를 사용하여 파라미터 전송하기 (0) | 2009.10.25 |
[FLEX] HTTPService 서비스 사용하기 - 데이터그리드 결과값 바인딩 (0) | 2009.10.25 |
[Chart] ColumnChart, BarChart
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.collections.ArrayCollection;
private var medalsAC:ArrayCollection = new ArrayCollection( [
{ Country: "USA", Gold: 35, Silver:39, Bronze: 29 },
{ Country: "China", Gold: 32, Silver:17, Bronze: 14 },
{ Country: "Korea", Gold: 10, Silver:47, Bronze: 140 },
{ Country: "Russia", Gold: 27, Silver:27, Bronze: 38 } ]);
]]>
</mx:Script>
<mx:SolidColor id="sc1" color="yellow" alpha=".5"/>
<mx:SolidColor id="sc2" color="0xCCCCCC" alpha=".5"/>
<mx:SolidColor id="sc3" color="0xFFCC66" alpha=".5"/>
<mx:Stroke id="s1" color="yellow" weight="1"/>
<mx:Stroke id="s2" color="0xCCCCCC" weight="1"/>
<mx:Stroke id="s3" color="0xFFCC66" weight="1"/>
height="100%" width="400" layout="vertical">
<mx:ColumnChart id="column"
height="50%"
width="70%"
paddingLeft="5"
paddingRight="5"
showDataTips="true"
dataProvider="{medalsAC}"
>
<mx:horizontalAxis>
<mx:CategoryAxis categoryField="Country"/>
</mx:horizontalAxis>
<mx:series>
<mx:ColumnSeries
xField="Country"
yField="Gold"
displayName="Gold"
fill="{sc1}"
stroke="{s1}"
/>
<mx:ColumnSeries
xField="Country"
yField="Silver"
displayName="Silver"
fill="{sc2}"
stroke="{s2}"
/>
<mx:ColumnSeries
xField="Country"
yField="Bronze"
displayName="Bronze"
fill="{sc3}"
stroke="{s3}"
/>
</mx:series>
</mx:ColumnChart>
<mx:Legend dataProvider="{column}"/>
<mx:BarChart id="bar" height="50%" width="70%"
paddingLeft="5" paddingRight="5"
showDataTips="true" dataProvider="{medalsAC}">
<mx:verticalAxis>
<mx:CategoryAxis categoryField="Country"/>
</mx:verticalAxis>
<mx:series>
<mx:BarSeries
yField="Country"
xField="Gold"
displayName="Gold"
fill="{sc1}"
stroke="{s1}"
/>
<mx:BarSeries
yField="Country"
xField="Silver"
displayName="Silver"
fill="{sc2}"
stroke="{s2}"
/>
<mx:BarSeries
yField="Country"
xField="Bronze"
displayName="Bronze"
fill="{sc3}"
stroke="{s3}"
/>
</mx:series>
</mx:BarChart>
<mx:Legend dataProvider="{bar}"/>
</mx:Panel>
</mx:Application>
'개발 > FLEX & AIR' 카테고리의 다른 글
[Flex] PieChart (0) | 2009.11.24 |
---|---|
[Flex] LineChart (0) | 2009.11.24 |
[FLEX] HTTPService를 사용하여 파라미터 전송하기 (0) | 2009.10.25 |
[FLEX] HTTPService 서비스 사용하기 - 데이터그리드 결과값 바인딩 (0) | 2009.10.25 |
crossdomain.xml (0) | 2009.10.25 |
[java] 저장소 정보 확인
하드디스크 정보를 확인하는 코드
FIle 클래스에 요런게 있는지는 오늘 알았네요 ^^;;
기초 공부 좀 많이 해야겠습니다.
package test; import java.io.File; public class Test { public static void main(String[] args) { File[] roots = File.listRoots(); for(File root: roots){ System.out.println("드라이브명 " + root.getAbsolutePath()); System.out.println("HDD 남은 공간 : " + root.getFreeSpace()); System.out.println("HDD 사용 가능 공간 : " + root.getUsableSpace()); System.out.println("HDD 사용 공간 : " + (root.getTotalSpace() - root.getFreeSpace())); } } }
'개발 > Java' 카테고리의 다른 글
[Java] 파일에 텍스트 이어서 쓰기 (0) | 2009.11.25 |
---|---|
[Spring] dbcp와 c3p0 커넥션 풀 유지하기 (0) | 2009.11.25 |
자주 쓰는 Maven 설정 정리 (0) | 2009.11.16 |
[ibatis]동적 컬럼 생성시 컬럼정보를 제대로 가져오지 못하는 현상 (1) | 2009.11.12 |
JSONObject를 이용한 json 사용하기 (0) | 2009.11.04 |