List of usage examples for java.io PrintWriter printf
public PrintWriter printf(Locale l, String format, Object... args)
From source file:de.tudarmstadt.ukp.dkpro.core.stanfordnlp.StanfordNamedEntityRecognizerTrainer.java
private void convert(JCas aJCas, PrintWriter aOut) { Type neType = JCasUtil.getType(aJCas, NamedEntity.class); Feature neValue = neType.getFeatureByBaseName("value"); // Named Entities IobEncoder neEncoder = new IobEncoder(aJCas.getCas(), neType, neValue, false); Map<Sentence, Collection<NamedEntity>> idx = JCasUtil.indexCovered(aJCas, Sentence.class, NamedEntity.class); Collection<NamedEntity> coveredNEs; for (Sentence sentence : select(aJCas, Sentence.class)) { coveredNEs = idx.get(sentence);// w ww . ja v a 2s. co m /* * don't include sentence in temp file that contains no annotations * * (saves memory for training) */ if (coveredNEs.isEmpty()) { continue; } HashMap<Token, Row> ctokens = new LinkedHashMap<>(); // Tokens List<Token> tokens = selectCovered(Token.class, sentence); for (Token token : tokens) { Row row = new Row(); row.token = token; row.ne = neEncoder.encode(token); ctokens.put(row.token, row); } // Write sentence in column format for (Row row : ctokens.values()) { aOut.printf("%s\t%s%n", row.token.getCoveredText(), row.ne); } aOut.println(); } }
From source file:kg12.Ex12_1.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*w w w . jav a2 s .c o m*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { out.println("<!DOCTYPE html>"); out.println("<html>"); out.println("<head>"); out.println("<title>Servlet Ex12_1</title>"); out.println("</head>"); out.println("<body>"); out.println("<h1>???</h1>"); // multipart/form-data ?? if (ServletFileUpload.isMultipartContent(request)) { out.println("???<br>"); } else { out.println("?????<br>"); out.close(); return; } // ServletFileUpload?? DiskFileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload sfu = new ServletFileUpload(factory); // ??? int fileSizeMax = 1024000; factory.setSizeThreshold(1024); sfu.setSizeMax(fileSizeMax); sfu.setHeaderEncoding("UTF-8"); // ? String format = "%s:%s<br>%n"; // ??????? FileItemIterator fileIt = sfu.getItemIterator(request); while (fileIt.hasNext()) { FileItemStream item = fileIt.next(); if (item.isFormField()) { // out.print("<br>??<br>"); out.printf(format, "??", item.getFieldName()); InputStream is = item.openStream(); // ? byte ?? byte[] b = new byte[255]; // byte? b ???? is.read(b, 0, b.length); // byte? b ? "UTF-8" ??String??? result ? String result = new String(b, "UTF-8"); out.printf(format, "", result); } else { // out.print("<br>??<br>"); out.printf(format, "??", item.getName()); } } out.println("</body>"); out.println("</html>"); } catch (FileUploadException e) { out.println(e + "<br>"); throw new ServletException(e); } catch (Exception e) { out.println(e + "<br>"); throw new ServletException(e); } finally { out.close(); } }
From source file:kg12.Ex12_2.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//w w w .j a va 2s. c om * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { out.println("<!DOCTYPE html>"); out.println("<html>"); out.println("<head>"); out.println("<title>Servlet Ex12_2</title>"); out.println("</head>"); out.println("<body>"); out.println("<h1>???</h1>"); // multipart/form-data ?? if (ServletFileUpload.isMultipartContent(request)) { out.println("???<br>"); } else { out.println("?????<br>"); out.close(); return; } // ServletFileUpload?? DiskFileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload sfu = new ServletFileUpload(factory); // ??? int fileSizeMax = 1024000; factory.setSizeThreshold(1024); sfu.setSizeMax(fileSizeMax); sfu.setHeaderEncoding("UTF-8"); // ? String format = "%s:%s<br>%n"; // ??????? FileItemIterator fileIt = sfu.getItemIterator(request); while (fileIt.hasNext()) { FileItemStream item = fileIt.next(); if (item.isFormField()) { // out.print("<br>??<br>"); out.printf(format, "??", item.getFieldName()); InputStream is = item.openStream(); // ? byte ?? byte[] b = new byte[255]; // byte? b ???? is.read(b, 0, b.length); // byte? b ? "UTF-8" ??String??? result ? String result = new String(b, "UTF-8"); out.printf(format, "", result); } else { // out.print("<br>??<br>"); out.printf(format, "??", item.getName()); InputStream is = item.openStream(); String fileName = item.getName(); int len = 0; byte[] buffer = new byte[fileSizeMax]; FileOutputStream fos = new FileOutputStream( "D:\\NetBeansProjects\\ap2_www\\web\\kg12\\" + fileName); try { while ((len = is.read(buffer)) > 0) { fos.write(buffer, 0, len); } } finally { fos.close(); } } } out.println("</body>"); out.println("</html>"); } catch (FileUploadException e) { out.println(e + "<br>"); throw new ServletException(e); } catch (Exception e) { out.println(e + "<br>"); throw new ServletException(e); } finally { out.close(); } }
From source file:tufts.vue.ds.Schema.java
public void dumpSchema(PrintWriter ps) { ps.println(getClass().getName() + ": " + toString()); final int pad = -mLongestFieldName; final String format = "%" + pad + "s: %s\n"; for (Field f : getFields()) { ps.printf(format, f.getName(), f.valuesDebug()); }/*from www. ja v a 2 s. c o m*/ //ps.println("Rows collected: " + rows.size()); }
From source file:edu.cornell.med.icb.goby.modes.SplitTranscriptsMode.java
/** * Perform the split transcripts mode./*www . j a v a2s . c o m*/ * * @throws IOException error reading / writing */ @Override public void execute() throws IOException { // Load the gene to transcripts file if (!config.validate()) { throw new IOException("Invalid SplitTranscripts configuration"); } final GeneTranscriptRelationships gtr = new GeneTranscriptRelationships(); final IndexedIdentifier transcriptIdents = new IndexedIdentifier(); final Int2ObjectMap<MutableString> transcriptIndexToIdMap = new Int2ObjectOpenHashMap<MutableString>(); final List<FastXEntry> fastxEntries = new LinkedList<FastXEntry>(); // // Pass through the file once to collect the transcript - gene relationships // int entryCount = 0; try { for (final FastXEntry entry : new FastXReader(config.getInputFile())) { entryCount++; parseHeader(entry.getEntryHeader()); final MutableString transcriptId = transcriptHeader.get("transcriptId"); final MutableString geneId = transcriptHeader.get("geneId"); final int transcriptIndex = transcriptIdents.registerIdentifier(transcriptId); gtr.addRelationship(geneId, transcriptIndex); transcriptIndexToIdMap.put(transcriptIndex, transcriptId); fastxEntries.add(entry.clone()); } } catch (CloneNotSupportedException e) { LOG.error("Couldn't clone for some reason", e); throw new GobyRuntimeException("Couldn't clone for some reason", e); } LOG.info("Loading map of genes-transcripts complete."); // // Scan through the transcript-gene relationships to determine which // transcript id goes into which file // final Int2IntMap transcriptIndex2FileIndex = new Int2IntOpenHashMap(); final String configOutputFilename = config.getOutputBase() + ".config"; final String configOutputPath = FilenameUtils.getFullPath(configOutputFilename); if (StringUtils.isNotBlank(configOutputPath)) { LOG.info("Creating output directory: " + configOutputPath); FileUtils.forceMkdir(new File(configOutputPath)); } PrintWriter configOutput = null; try { configOutput = new PrintWriter(configOutputFilename); configOutput.println("Ensembl Gene ID\tEnsembl Transcript ID"); final Int2IntMap fileIndex2NumberOfEntries = new Int2IntOpenHashMap(); fileIndex2NumberOfEntries.defaultReturnValue(0); transcriptIndex2FileIndex.defaultReturnValue(-1); final int initialNumberOfFiles = getNumberOfFiles(gtr, transcriptIndex2FileIndex); for (int geneIndex = 0; geneIndex < gtr.getNumberOfGenes(); geneIndex++) { final MutableString geneId = gtr.getGeneId(geneIndex); final IntSet transcriptIndices = gtr.getTranscriptSet(geneIndex); int fileNum = 0; for (final int transcriptIndex : transcriptIndices) { if (transcriptIndex2FileIndex.get(transcriptIndex) != -1) { LOG.warn("Skipping repeated transcriptIndex: " + transcriptIndex); continue; } final int maxEntriesPerFile = config.getMaxEntriesPerFile(); final int numberOfEntriesInOriginalBucket = fileIndex2NumberOfEntries.get(fileNum); final int adjustedFileIndex = fileNum + initialNumberOfFiles * (numberOfEntriesInOriginalBucket / maxEntriesPerFile); transcriptIndex2FileIndex.put(transcriptIndex, adjustedFileIndex); fileIndex2NumberOfEntries.put(fileNum, fileIndex2NumberOfEntries.get(fileNum) + 1); final MutableString transcriptId = transcriptIndexToIdMap.get(transcriptIndex); configOutput.printf("%s\t%s%n", geneId, transcriptId); fileNum++; } } } finally { IOUtils.closeQuietly(configOutput); } final int numFiles = getFileIndices(transcriptIndex2FileIndex).size(); if (LOG.isInfoEnabled()) { LOG.info(NumberFormat.getInstance().format(entryCount) + " entries will be written to " + numFiles + " files"); final int maxEntriesPerFile = config.getMaxEntriesPerFile(); if (maxEntriesPerFile < Integer.MAX_VALUE) { LOG.info("Each file will contain at most " + maxEntriesPerFile + " entries"); } } // formatter for uniquely numbering files each with the same number of digits final NumberFormat fileNumberFormatter = getNumberFormatter(numFiles - 1); final ProgressLogger progressLogger = new ProgressLogger(); progressLogger.expectedUpdates = entryCount; progressLogger.itemsName = "entries"; progressLogger.start(); // Write each file one at a time rather than in the order they appear in the input file // to avoid the issue of having too many streams open at the same or continually opening // and closing streams which is quite costly. We could store the gene/transcripts in // memory and then just write the files at the end but that could be worse. for (final int fileIndex : getFileIndices(transcriptIndex2FileIndex)) { final String filename = config.getOutputBase() + "." + fileNumberFormatter.format(fileIndex) + ".fa.gz"; PrintStream printStream = null; try { // each file is compressed printStream = new PrintStream(new GZIPOutputStream(new FileOutputStream(filename))); // // Read through the input file get the actual sequence information // final Iterator<FastXEntry> entries = fastxEntries.iterator(); while (entries.hasNext()) { final FastXEntry entry = entries.next(); parseHeader(entry.getEntryHeader()); final MutableString transcriptId = transcriptHeader.get("transcriptId"); final MutableString geneId = transcriptHeader.get("geneId"); final int transcriptIndex = transcriptIdents.getInt(transcriptId); final int transcriptFileIndex = transcriptIndex2FileIndex.get(transcriptIndex); if (transcriptFileIndex == fileIndex) { printStream.print(entry.getHeaderSymbol()); printStream.print(transcriptId); printStream.print(" gene:"); printStream.println(geneId); printStream.println(entry.getEntrySansHeader()); entries.remove(); progressLogger.lightUpdate(); } } } finally { IOUtils.closeQuietly(printStream); } } assert progressLogger.count == entryCount : "Some entries were not processed!"; progressLogger.done(); }
From source file:pt.ist.fenixedu.contracts.tasks.giafsync.ImportProfessionalRegimesFromGiaf.java
@Override public void processChanges(GiafMetadata metadata, PrintWriter log, Logger logger) throws Exception { int updatedRegimes = 0; int newRegimes = 0; PersistentSuportGiaf oracleConnection = PersistentSuportGiaf.getInstance(); String query = getQuery();/*from w w w . j a v a 2 s . c o m*/ PreparedStatement preparedStatement = oracleConnection.prepareStatement(query); ResultSet result = preparedStatement.executeQuery(); while (result.next()) { String giafId = result.getString("emp_regime"); String regimeName = result.getString("regime_dsc"); Integer weighting = result.getInt("regime_pond"); BigDecimal fullTimeEquivalent = result.getBigDecimal("valor_eti"); CategoryType categoryType = null; if (!StringUtils.isBlank(regimeName)) { if (regimeName.contains("Bolseiro")) { categoryType = CategoryType.GRANT_OWNER; } else if (regimeName.contains("Investigador")) { categoryType = CategoryType.RESEARCHER; } else if (regimeName.contains("Pessoal no Docente") || regimeName.contains("Pess. no Doc.") || regimeName.contains("Pessoal No Docente")) { categoryType = CategoryType.EMPLOYEE; } else if (regimeName.contains("(Docentes)") || regimeName.contains("(Doc)")) { categoryType = CategoryType.TEACHER; } } ProfessionalRegime professionalRegime = metadata.regime(giafId); MultiLanguageString name = new MultiLanguageString(MultiLanguageString.pt, regimeName); if (professionalRegime != null) { if (!isEqual(professionalRegime, name, weighting, fullTimeEquivalent, categoryType)) { professionalRegime.edit(name, weighting, fullTimeEquivalent, categoryType); updatedRegimes++; } } else { metadata.registerRegime(giafId, weighting, fullTimeEquivalent, categoryType, name); newRegimes++; } } result.close(); preparedStatement.close(); oracleConnection.closeConnection(); log.printf("Regimes: %d updated, %d new\n", updatedRegimes, newRegimes); }
From source file:cnu.eslab.fileTest.NewJFrame.java
@Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub if (e.getSource() == mFileBtn) { if (mJFileChooser != null) { // ? ?? ?. if (mFileName != null) { String dir = mFileName.getAbsolutePath(); // ?? // . mJFileChooser = new JFileChooser(dir); }/*from w w w . j a va 2s . c o m*/ int returnVal = mJFileChooser.showOpenDialog(this); if (returnVal != JFileChooser.APPROVE_OPTION) return; // . mFileName = mJFileChooser.getSelectedFile(); mFilePathTextField.setText(mFileName.getAbsolutePath()); } } else if (e.getSource() == mGPSCheckBox) { FLAG_GPS_STATE = mGPSCheckBox.isSelected(); } else if (e.getSource() == mAudioCheckBox) { FLAG_AUDIO_STATE = mAudioCheckBox.isSelected(); } else if (e.getSource() == mParsingBtn) { // List . listModel.clear(); // ? ?? ? . mCFileStream.setFileName(mFileName.getAbsolutePath()); // UID ? . ? . try { mUidArrayList = mCFileStream.ParsingUID(); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } for (int i = 0; i < mUidArrayList.size(); i++) { listModel.addElement(mUidArrayList.get(i)); } } else if (e.getSource() == mTotalPowerBtn) { try { int LastUnit = 50; // ? ?. double totalSum = 0.0, mean = 0.0; // ? ? . mTotalPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, TOTAL_POWER); // ? . mTimeArrayList = mCFileStream.ParsingTime(); //? PrintWriter out = new PrintWriter(new FileWriter("TotalPower.txt")); for (int i = 0; i < mTotalPowerArrayList.size(); i++) { out.printf("%s %d\n", mTimeArrayList.get(i), mTotalPowerArrayList.get(i)); out.flush(); } out.close(); /* // 50 ?? . for (int i = 0; i < mTotalPowerArrayList.size(); i += 50) { totalSum = 0.0; // . mean = 0.0; for (int j = 0; j < 50; j++) { if ((j + i) >= mTotalPowerArrayList.size()) { LastUnit = j; break; // ??? . } totalSum += mTotalPowerArrayList.get(j + i); } mean = totalSum / LastUnit; System.out.printf("%f\n", mean); }*/ LineGraphGenerate(mTotalPowerArrayList, "Line Graph", "Total Power Consumption", "Total Power Value"); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } //? stack ? else if (e.getSource() == mPhoneTotalStackPowerBtn) { try { // ? if (listModelUidDelte.getSize() == 0) { //? H/W component Stack Grap? . ? Grap? Line? ? ? ?. StackedXYAreaRenderer(mCFileStream.ParsingPowerConsumption(mSearchUid, TOTAL_CPU_POWER), mCFileStream.ParsingPowerConsumption(mSearchUid, TOTAL_WIFI_POWER), mCFileStream.ParsingPowerConsumption(mSearchUid, TOTAL_LED_POWER), mCFileStream.ParsingPowerConsumption(mSearchUid, GPS_POWER), mCFileStream.ParsingPowerConsumption(mSearchUid, AUDIO_POWER), mCFileStream.ParsingPowerConsumption(mSearchUid, TOTAL_THREEG_POWER)); } else { //? ? arraylist? . mCpuPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, TOTAL_CPU_POWER); mWifiPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, TOTAL_WIFI_POWER); mLedPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, TOTAL_LED_POWER); mThreeGPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, TOTAL_THREEG_POWER); mGpsPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, GPS_POWER); mAudioPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, AUDIO_POWER); // ? UID? Power? ? ? ArrayList . processUidDeletePower(); //CPU,WIFI,LED,GPS,AUDIO,3G . StackedXYAreaRenderer(mCpuPowerArrayList, mWifiPowerArrayList, mLedPowerArrayList, mGpsPowerArrayList, mAudioPowerArrayList, mThreeGPowerArrayList); } } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } else if (e.getSource() == mBatteryCapacityBtn) { try { mBatteryCapacityArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, BATTERY_CAPACITY); LineGraphGenerate(mBatteryCapacityArrayList, "Line Graph", "Battery Capacity", "Battery Capacity (%)"); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } else if (e.getSource() == mCpuBtn) { try { mCpuPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, CPU_POWER); LineGraphGenerate(mCpuPowerArrayList, "Line Graph", "CPU Power Consumption", "CPU Power Value"); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } else if (e.getSource() == mWifiBtn) { try { mWifiPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, WIFI_POWER); LineGraphGenerate(mWifiPowerArrayList, "Line Graph", "WIFI Power Consumption", "WIFI Power Value"); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } else if (e.getSource() == m3GBtn) { try { mThreeGPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, THREEG_POWER); LineGraphGenerate(mThreeGPowerArrayList, "Line Graph", "ThreeG Power Consumption", "ThreeG Power Value"); } catch (FileNotFoundException e1) { e1.printStackTrace(); } } else if (e.getSource() == mLedBtn) { try { mLedPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, LED_POWER); LineGraphGenerate(mLedPowerArrayList, "Line Graph", "LED Power Consumption", "LED Power Value"); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } else if (e.getSource() == mGpsBtn) { try { mGpsPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, GPS_POWER); LineGraphGenerate(mGpsPowerArrayList, "Line Graph", "GPS Power Consumption", "GPS Power Value"); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } else if (e.getSource() == mAudioBtn) { try { mAudioPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, AUDIO_POWER); LineGraphGenerate(mAudioPowerArrayList, "Line Graph", "AUDIO Power Consumption", "Audio Power Value"); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } //? ? . (UID ? .) else if (e.getSource() == mComponentWIFIBtn) { try { mComponentWifiArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, TOTAL_WIFI_POWER); LineGraphGenerate(mComponentWifiArrayList, "Line Graph", "ComponentWifi Power Consumption", "ComponentWifi Power Value"); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } // ? ? ?. else if (e.getSource() == mDevicesPowerButton) { int maxCPU = 0; int maxWIFI = 0; int maxThree = 0; int maxLED = 0; int maxGPS = 0; int maxAUDIO = 0; try { maxCPU = maxEvaluation(mCFileStream.ParsingPowerConsumption(mSearchUid, TOTAL_CPU_POWER)); maxWIFI = maxEvaluation(mCFileStream.ParsingPowerConsumption(mSearchUid, TOTAL_WIFI_POWER)); maxThree = maxEvaluation(mCFileStream.ParsingPowerConsumption(mSearchUid, TOTAL_THREEG_POWER)); maxLED = maxEvaluation(mCFileStream.ParsingPowerConsumption(mSearchUid, TOTAL_LED_POWER)); maxGPS = maxEvaluation(mCFileStream.ParsingPowerConsumption(mSearchUid, GPS_POWER)); maxAUDIO = maxEvaluation(mCFileStream.ParsingPowerConsumption(mSearchUid, AUDIO_POWER)); System.out.println("CPU " + maxCPU); System.out.println("WIFI " + maxWIFI); System.out.println("3G " + maxThree); System.out.println("LED " + maxLED); System.out.println("GPS " + maxGPS); System.out.println("AUDIO " + maxAUDIO); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } //Component Pipe Diagram make function. else if (e.getSource() == mComponentPieBtn) { double[] value = new double[6]; String[] group = new String[6]; group[0] = "CPU Power"; group[1] = "WIFI Power"; group[2] = "LED Power"; group[3] = "GPS Power"; group[4] = "AUDIO Power"; group[5] = "3G Power"; value[0] = 0.0; value[1] = 0.0; value[2] = 0.0; value[3] = 0.0; value[4] = 0.0; value[5] = 0.0; int totalPowerValue = 0; if (mFirstRangeText.getText() != "") { // . mFirstRange = Integer.parseInt(mFirstRangeText.getText()); mSecondRange = Integer.parseInt(mSecondRangeText.getText()); // ? ?. try { mCpuPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, TOTAL_CPU_POWER); mWifiPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, TOTAL_WIFI_POWER); mLedPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, TOTAL_LED_POWER); mGpsPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, GPS_POWER); mAudioPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, AUDIO_POWER); mThreeGPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, TOTAL_THREEG_POWER); processUidDeletePower(); // ? ? . for (int i = mFirstRange; i <= mSecondRange; i++) { // ? ? . value[0] += (double) mCpuPowerArrayList.get(i); value[1] += (double) mWifiPowerArrayList.get(i); value[2] += (double) mLedPowerArrayList.get(i); value[5] += (double) mThreeGPowerArrayList.get(i); if (FLAG_GPS_STATE == true && FLAG_AUDIO_STATE == true) { value[3] += (double) mGpsPowerArrayList.get(i); value[4] += (double) mAudioPowerArrayList.get(i); } else if (FLAG_GPS_STATE == true && FLAG_AUDIO_STATE == false) { value[3] += (double) mGpsPowerArrayList.get(i); value[4] = 0.0; } else if (FLAG_GPS_STATE == false && FLAG_AUDIO_STATE == true) { value[3] = 0.0; value[4] += (double) mAudioPowerArrayList.get(i); } } } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } PieGraphGenerate(group, value, "", ""); } } // Pipe ?? ? ?? else if (e.getSource() == mUidPieDiagramBtn) { double[] value = new double[6]; String[] group = new String[6]; group[0] = "CPU Power"; group[1] = "WIFI Power"; group[2] = "LED Power"; group[3] = "GPS Power"; group[4] = "AUDIO Power"; group[5] = "3G Power"; value[0] = 0.0; value[1] = 0.0; value[2] = 0.0; value[3] = 0.0; value[4] = 0.0; value[5] = 0.0; int totalPowerValue = 0; if (mFirstRangeText.getText() != "") { // . mFirstRange = Integer.parseInt(mFirstRangeText.getText()); mSecondRange = Integer.parseInt(mSecondRangeText.getText()); // ? ?. try { mCpuPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, CPU_POWER); mWifiPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, WIFI_POWER); mLedPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, LED_POWER); mGpsPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, GPS_POWER); mAudioPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, AUDIO_POWER); mThreeGPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, THREEG_POWER); // ? ?? ?. mTotalPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, TOTAL_POWER); for (int i = mFirstRange; i <= mSecondRange; i++) { // ? ? . value[0] += (double) mCpuPowerArrayList.get(i); value[1] += (double) mWifiPowerArrayList.get(i); value[2] += (double) mLedPowerArrayList.get(i); value[5] += (double) mThreeGPowerArrayList.get(i); if (FLAG_GPS_STATE == true && FLAG_AUDIO_STATE == true) { value[3] += (double) mGpsPowerArrayList.get(i); value[4] += (double) mAudioPowerArrayList.get(i); } else if (FLAG_GPS_STATE == true && FLAG_AUDIO_STATE == false) { value[3] += (double) mGpsPowerArrayList.get(i); value[4] = 0.0; } else if (FLAG_GPS_STATE == false && FLAG_AUDIO_STATE == true) { value[3] = 0.0; value[4] += (double) mAudioPowerArrayList.get(i); } totalPowerValue += mTotalPowerArrayList.get(i); } System.out.println(totalPowerValue); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } PieGraphGenerate(group, value, "", ""); } } //Component . else if (e.getSource() == mComponentLEDBtn) { } // 3D bar chart Range? ?? . else if (e.getSource() == m3DBarChartMean) { int unit = 0; int sumCPU = 0; int sumWIFI = 0; int sumLED = 0; int sumGPS = 0; int sumAUDIO = 0; int sumThree = 0; int totalsum = 0; int powtotalsum = 0; int LastUnit = 0; double mean; double totalmean; double Powe2mean; boolean flagGPS = false; boolean flagAUDIO = false; // ? ? ? . flagGPS = mGPSCheckBox.isSelected(); flagAUDIO = mAudioCheckBox.isSelected(); ArrayList<Double> mTotalArrayList = new ArrayList<Double>(); ArrayList<Double> mUnitCPUArrayList = new ArrayList<Double>(); ArrayList<Double> mUnitWIFIPowerArrayList = new ArrayList<Double>(); ArrayList<Double> mUnitThreePowerArrayList = new ArrayList<Double>(); ArrayList<Double> mUnitLEDPowerArrayList = new ArrayList<Double>(); ArrayList<Double> mUnitGPSPowerArrayList = new ArrayList<Double>(); ArrayList<Double> mUnitAUDIOPowerArrayList = new ArrayList<Double>(); if (mChartMeanUnitTextField.getText() != "") { unit = Integer.parseInt(mChartMeanUnitTextField.getText()); // ?? ? ?? ? ?. (e.g 1 ?? ?? 40 // ? ? ? ?. // ? ?? ? ? . LastUnit = Integer.parseInt(mChartMeanUnitTextField.getText()); } // ? Power ? . try { mCpuPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, TOTAL_CPU_POWER); mWifiPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, TOTAL_WIFI_POWER); mThreeGPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, TOTAL_THREEG_POWER); mLedPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, TOTAL_LED_POWER); mGpsPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, GPS_POWER); mAudioPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, AUDIO_POWER); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } // list . processUidDeletePower(); // unit ? ?? . for (int i = 0; i < mCpuPowerArrayList.size(); i += unit) { sumCPU = 0; sumWIFI = 0; sumThree = 0; sumLED = 0; sumGPS = 0; sumAUDIO = 0; totalsum = 0; powtotalsum = 0; for (int j = 0; j < unit; j++) { if ((j + i) >= mCpuPowerArrayList.size()) { // ? . ? ?? ?. LastUnit = j; // ? ? . break; } sumCPU += mCpuPowerArrayList.get(j + i); sumWIFI += mWifiPowerArrayList.get(j + i); sumThree += mThreeGPowerArrayList.get(j + i); sumLED += mLedPowerArrayList.get(j + i); // ? ? ? . if (flagGPS == true && flagAUDIO == true) { sumGPS += mGpsPowerArrayList.get(j + i); sumAUDIO += mAudioPowerArrayList.get(j + i); totalsum = mCpuPowerArrayList.get(j + i) + mWifiPowerArrayList.get(j + i) + mThreeGPowerArrayList.get(j + i) + mLedPowerArrayList.get(j + i) + mGpsPowerArrayList.get(j + i) + mAudioPowerArrayList.get(j + i); } else if (flagGPS == true && flagAUDIO == false) { sumGPS += mGpsPowerArrayList.get(j + i); totalsum = mCpuPowerArrayList.get(j + i) + mWifiPowerArrayList.get(j + i) + mThreeGPowerArrayList.get(j + i) + mLedPowerArrayList.get(j + i) + mGpsPowerArrayList.get(j + i); } else if (flagGPS == false && flagAUDIO == true) { sumAUDIO += mAudioPowerArrayList.get(j + i); totalsum = mCpuPowerArrayList.get(j + i) + mWifiPowerArrayList.get(j + i) + mThreeGPowerArrayList.get(j + i) + mLedPowerArrayList.get(j + i) + mAudioPowerArrayList.get(j + i); } else { totalsum = mCpuPowerArrayList.get(j + i) + mWifiPowerArrayList.get(j + i) + mThreeGPowerArrayList.get(j + i) + mLedPowerArrayList.get(j + i); } powtotalsum += (int) Math.pow(totalsum, 2); totalsum = 0; } /* * LastUnit? break? ? ? ? . ? ?? * ? ? ? ? ? . */ mean = sumCPU / LastUnit; mUnitCPUArrayList.add(mean); mean = sumWIFI / LastUnit; mUnitWIFIPowerArrayList.add(mean); mean = sumThree / LastUnit; mUnitThreePowerArrayList.add(mean); mean = sumLED / LastUnit; mUnitLEDPowerArrayList.add(mean); if ((flagGPS == true) && (flagAUDIO == true)) { mean = sumGPS / LastUnit; mUnitGPSPowerArrayList.add(mean); mean = sumAUDIO / LastUnit; mUnitAUDIOPowerArrayList.add(mean); totalmean = (sumCPU + sumWIFI + sumThree + sumLED + sumGPS + sumAUDIO) / LastUnit; // . Powe2mean = Math.sqrt((powtotalsum / LastUnit) - Math.pow(((sumCPU + sumWIFI + sumThree + sumLED + sumGPS + sumAUDIO) / LastUnit), 2)); // ? . /* System.out.println((i / 60) + ": ?: " + totalmean + " : " + Powe2mean);*/ System.out.println("" + totalmean); } else if ((flagGPS == true) && (flagAUDIO == false)) { mean = sumGPS / LastUnit; mUnitGPSPowerArrayList.add(mean); mUnitAUDIOPowerArrayList.add(0.0); totalmean = (sumCPU + sumWIFI + sumLED + sumGPS) / LastUnit; // . Powe2mean = Math.sqrt((powtotalsum / LastUnit) - Math.pow(((sumCPU + sumWIFI + sumThree + sumLED + sumGPS) / LastUnit), 2)); /*System.out.println((i / 60) + ": ?: " + totalmean + " : " + Powe2mean);*/ System.out.println("" + totalmean); } else if (flagGPS == false && flagAUDIO == true) { mUnitGPSPowerArrayList.add(0.0); mean = sumAUDIO / LastUnit; mUnitAUDIOPowerArrayList.add(mean); totalmean = (sumCPU + sumWIFI + sumLED + sumAUDIO) / LastUnit; // . Powe2mean = Math.sqrt((powtotalsum / LastUnit) - Math.pow(((sumCPU + sumWIFI + sumThree + sumLED + sumAUDIO) / LastUnit), 2)); /*System.out.println((i / 60) + ": ?: " + totalmean + " : " + Powe2mean);*/ System.out.println("" + totalmean); } else { mUnitGPSPowerArrayList.add(0.0); mUnitAUDIOPowerArrayList.add(0.0); totalmean = (sumCPU + sumWIFI + sumLED) / LastUnit; // . Powe2mean = Math.sqrt((powtotalsum / LastUnit) - Math.pow(((sumCPU + sumWIFI + sumThree + sumLED) / LastUnit), 2)); /*System.out.println((i / 60) + ": ?: " + totalmean + " : " + Powe2mean);*/ System.out.println("" + totalmean); } } for (int i = 0; i < mUnitCPUArrayList.size(); i++) { double sum = mUnitCPUArrayList.get(i) + mUnitWIFIPowerArrayList.get(i) + mUnitThreePowerArrayList.get(i) + mUnitLEDPowerArrayList.get(i) + mUnitGPSPowerArrayList.get(i) + mUnitAUDIOPowerArrayList.get(i); System.out.println("" + sum); } // 3D bar chart ? . StackedBarChart3D(mUnitCPUArrayList, mUnitWIFIPowerArrayList, mUnitThreePowerArrayList, mUnitLEDPowerArrayList, mUnitGPSPowerArrayList, mUnitAUDIOPowerArrayList); } // ? App Line ?. else if (e.getSource() == mAppTotalPowerBtn) { int totalPower; ArrayList<Integer> mUidTotalPowerArrayList = new ArrayList<Integer>(); try { mCpuPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, CPU_POWER); mWifiPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, WIFI_POWER); mLedPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, LED_POWER); mGpsPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, GPS_POWER); mAudioPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, AUDIO_POWER); /* log ? */ mLogScaleTextFiled.setText(String.format("%d", mCpuPowerArrayList.size() - 1)); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } // uid ? Line Grahp . for (int i = 0; i < mCpuPowerArrayList.size(); i++) { totalPower = mCpuPowerArrayList.get(i) + mWifiPowerArrayList.get(i) + mLedPowerArrayList.get(i); if (FLAG_GPS_STATE == true && FLAG_AUDIO_STATE == true) { totalPower += mGpsPowerArrayList.get(i) + mAudioPowerArrayList.get(i); } else if (FLAG_GPS_STATE == true && FLAG_AUDIO_STATE == false) { totalPower += mGpsPowerArrayList.get(i); } else if (FLAG_GPS_STATE == false && FLAG_AUDIO_STATE == true) { totalPower += mAudioPowerArrayList.get(i); } mUidTotalPowerArrayList.add(totalPower); } LineGraphGenerate(mUidTotalPowerArrayList, "Line Graph", "App Total Power", "Power Value"); } // ? App XY Area ?. else if (e.getSource() == mAppStackedPower) { try { mCpuPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, CPU_POWER); mWifiPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, WIFI_POWER); mLedPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, LED_POWER); mGpsPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, GPS_POWER); mAudioPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, AUDIO_POWER); mThreeGPowerArrayList = mCFileStream.ParsingPowerConsumption(mSearchUid, THREEG_POWER); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } StackedXYAreaRenderer(mCpuPowerArrayList, mWifiPowerArrayList, mLedPowerArrayList, mGpsPowerArrayList, mAudioPowerArrayList, mThreeGPowerArrayList); } // List? ??? else if (e.getSource() == mDeleteUidMoveBtn) { listModelUidDelte.addElement(mSearchUid); //? UID UID List ?? . } // List? UID else if (e.getSource() == mDeleteAllBtn) { listModelUidDelte.clear(); } // List? ? UID else if (e.getSource() == mDeleteOneBtn) { listModelUidDelte.remove(mDeleteList.getSelectedIndex()); } //? ? ?. else if (e.getSource() == mTotalCompareBtn) { DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset(); DefaultStatisticalCategoryDataset defaultstatisticalcategorydataset = new DefaultStatisticalCategoryDataset(); //? (?) sd 157.97 defaultcategorydataset.addValue(167, "CPU Power(mW)", "MYPEOPLE-Voice"); defaultcategorydataset.addValue(400, "WIFI Power(mW)", "MYPEOPLE-Voice"); defaultcategorydataset.addValue(0, "3G Power(mW)", "MYPEOPLE-Voice"); defaultcategorydataset.addValue(0, "LED Power(mW)", "MYPEOPLE-Voice"); defaultcategorydataset.addValue(0, "GPS Power(mW)", "MYPEOPLE-Voice"); defaultcategorydataset.addValue(0, "AUDIO Power(mW)", "MYPEOPLE-Voice"); //?(??) sd 144.44 defaultcategorydataset.addValue(197, "CPU Power(mW)", "MYPEOPLE-Video"); defaultcategorydataset.addValue(404, "WIFI Power(mW)", "MYPEOPLE-Video"); defaultcategorydataset.addValue(0, "3G Power(mW)", "MYPEOPLE-Video"); defaultcategorydataset.addValue(399, "LED Power(mW)", "MYPEOPLE-Video"); defaultcategorydataset.addValue(0, "GPS Power(mW)", "MYPEOPLE-Video"); defaultcategorydataset.addValue(0, "AUDIO Power(mW)", "MYPEOPLE-Video"); // sd : 246.80 defaultcategorydataset.addValue(91, "CPU Power(mW)", "KAKAo-Talk"); defaultcategorydataset.addValue(110, "WIFI Power(mW)", "KAKAo-Talk"); defaultcategorydataset.addValue(0, "3G Power(mW)", "KAKAo-Talk"); defaultcategorydataset.addValue(454, "LED Power(mW)", "KAKAo-Talk"); defaultcategorydataset.addValue(0, "GPS Power(mW)", "KAKAo-Talk"); defaultcategorydataset.addValue(0, "AUDIO Power(mW)", "KAKAo-Talk"); // sd : 188.30 defaultcategorydataset.addValue(134, "CPU Power(mW)", "Angry-Birds"); defaultcategorydataset.addValue(66, "WIFI Power(mW)", "Angry-Birds"); defaultcategorydataset.addValue(0, "3G Power(mW)", "Angry-Birds"); defaultcategorydataset.addValue(528, "LED Power(mW)", "Angry-Birds"); defaultcategorydataset.addValue(0, "GPS Power(mW)", "Angry-Birds"); defaultcategorydataset.addValue(103, "AUDIO Power(mW)", "Angry-Birds"); // sd : 233.50 defaultcategorydataset.addValue(40, "CPU Power(mW)", "Youtube"); defaultcategorydataset.addValue(131, "WIFI Power(mW)", "Youtube"); defaultcategorydataset.addValue(0, "3G Power(mW)", "Youtube"); defaultcategorydataset.addValue(474, "LED Power(mW)", "Youtube"); defaultcategorydataset.addValue(0, "GPS Power(mW)", "Youtube"); defaultcategorydataset.addValue(91, "AUDIO Power(mW)", "Youtube"); //? sd : 301.80 defaultcategorydataset.addValue(382, "CPU Power(mW)", "Web-Browser"); defaultcategorydataset.addValue(0, "WIFI Power(mW)", "Web-Browser"); defaultcategorydataset.addValue(823, "3G Power(mW)", "Web-Browser"); defaultcategorydataset.addValue(570, "LED Power(mW)", "Web-Browser"); defaultcategorydataset.addValue(0, "GPS Power(mW)", "Web-Browser"); defaultcategorydataset.addValue(0, "AUDIO Power(mW)", "Web-Browser"); defaultcategorydataset.addValue(60, "CPU Power(mW)", "Google-Map"); defaultcategorydataset.addValue(0, "WIFI Power(mW)", "Google-Map"); defaultcategorydataset.addValue(750, "3G Power(mW)", "Google-Map"); defaultcategorydataset.addValue(538, "LED Power(mW)", "Google-Map"); defaultcategorydataset.addValue(244, "GPS Power(mW)", "Google-Map"); defaultcategorydataset.addValue(0, "AUDIO Power(mW)", "Google-Map"); JFreeChart jfreechart = ChartFactory.createStackedBarChart3D("", "Application Name", "Power(mW)", defaultcategorydataset, PlotOrientation.HORIZONTAL, true, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(new Color(255, 255, 255));// // ? ?. // IntervalMarker intervalmarker = new IntervalMarker(5D, 10D, // Color.gray, new BasicStroke(0.5F), Color.blue, new BasicStroke(0.5F), // 0.5F); // categoryplot.addRangeMarker(intervalmarker); BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setDrawBarOutline(false); barrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); barrenderer.setBaseItemLabelsVisible(true); barrenderer.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); barrenderer.setBaseNegativeItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); // JFrame? ?. ChartPanel chartPanel = new ChartPanel(jfreechart); JFrame f = new JFrame(""); f.setSize(600, 600); f.getContentPane().add(chartPanel); // f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); } // ? ? ? . else if (e.getSource() == mCompareAppPowerBtn) { DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset(); DefaultStatisticalCategoryDataset defaultstatisticalcategorydataset = new DefaultStatisticalCategoryDataset(); //? (?) sd 38.6 defaultcategorydataset.addValue(313, "CPU Power(mW)", "MYPEOPLE-Voice"); defaultcategorydataset.addValue(404, "WIFI Power(mW)", "MYPEOPLE-Voice"); defaultcategorydataset.addValue(0, "3G Power(mW)", "MYPEOPLE-Voice"); defaultcategorydataset.addValue(0, "LED Power(mW)", "MYPEOPLE-Voice"); defaultcategorydataset.addValue(0, "GPS Power(mW)", "MYPEOPLE-Voice"); defaultcategorydataset.addValue(0, "AUDIO Power(mW)", "MYPEOPLE-Voice"); //?(??) sd 144.44 defaultcategorydataset.addValue(277, "CPU Power(mW)", "MYPEOPLE-Video"); defaultcategorydataset.addValue(396, "WIFI Power(mW)", "MYPEOPLE-Video"); defaultcategorydataset.addValue(0, "3G Power(mW)", "MYPEOPLE-Video"); defaultcategorydataset.addValue(411, "LED Power(mW)", "MYPEOPLE-Video"); defaultcategorydataset.addValue(0, "GPS Power(mW)", "MYPEOPLE-Video"); defaultcategorydataset.addValue(0, "AUDIO Power(mW)", "MYPEOPLE-Video"); defaultcategorydataset.addValue(93, "CPU Power(mW)", "KAKAo-Talk"); defaultcategorydataset.addValue(166, "WIFI Power(mW)", "KAKAo-Talk"); defaultcategorydataset.addValue(0, "3G Power(mW)", "KAKAo-Talk"); defaultcategorydataset.addValue(465, "LED Power(mW)", "KAKAo-Talk"); defaultcategorydataset.addValue(0, "GPS Power(mW)", "KAKAo-Talk"); defaultcategorydataset.addValue(0, "AUDIO Power(mW)", "KAKAo-Talk"); defaultcategorydataset.addValue(149, "CPU Power(mW)", "Angry-Birds"); defaultcategorydataset.addValue(88, "WIFI Power(mW)", "Angry-Birds"); defaultcategorydataset.addValue(0, "3G Power(mW)", "Angry-Birds"); defaultcategorydataset.addValue(534, "LED Power(mW)", "Angry-Birds"); defaultcategorydataset.addValue(0, "GPS Power(mW)", "Angry-Birds"); defaultcategorydataset.addValue(106, "AUDIO Power(mW)", "Angry-Birds"); defaultcategorydataset.addValue(32, "CPU Power(mW)", "Youtube"); defaultcategorydataset.addValue(136, "WIFI Power(mW)", "Youtube"); defaultcategorydataset.addValue(0, "3G Power(mW)", "Youtube"); defaultcategorydataset.addValue(520, "LED Power(mW)", "Youtube"); defaultcategorydataset.addValue(0, "GPS Power(mW)", "Youtube"); defaultcategorydataset.addValue(103, "AUDIO Power(mW)", "Youtube"); defaultcategorydataset.addValue(411, "CPU Power(mW)", "Web-Browser"); defaultcategorydataset.addValue(0, "WIFI Power(mW)", "Web-Browser"); defaultcategorydataset.addValue(883, "3G Power(mW)", "Web-Browser"); defaultcategorydataset.addValue(626, "LED Power(mW)", "Web-Browser"); defaultcategorydataset.addValue(0, "GPS Power(mW)", "Web-Browser"); defaultcategorydataset.addValue(0, "AUDIO Power(mW)", "Web-Browser"); defaultcategorydataset.addValue(94, "CPU Power(mW)", "Google-Map"); defaultcategorydataset.addValue(0, "WIFI Power(mW)", "Google-Map"); defaultcategorydataset.addValue(902, "3G Power(mW)", "Google-Map"); defaultcategorydataset.addValue(581, "LED Power(mW)", "Google-Map"); defaultcategorydataset.addValue(268, "GPS Power(mW)", "Google-Map"); defaultcategorydataset.addValue(0, "AUDIO Power(mW)", "Google-Map"); JFreeChart jfreechart = ChartFactory.createStackedBarChart3D("", "Application Name", "Power(mW)", defaultcategorydataset, PlotOrientation.HORIZONTAL, true, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(new Color(255, 255, 255));// // ? ?. // IntervalMarker intervalmarker = new IntervalMarker(5D, 10D, // Color.gray, new BasicStroke(0.5F), Color.blue, new BasicStroke(0.5F), // 0.5F); // categoryplot.addRangeMarker(intervalmarker); BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setDrawBarOutline(false); barrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); barrenderer.setBaseItemLabelsVisible(true); barrenderer.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); barrenderer.setBaseNegativeItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); // JFrame? ?. ChartPanel chartPanel = new ChartPanel(jfreechart); JFrame f = new JFrame(""); f.setSize(600, 600); f.getContentPane().add(chartPanel); // f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); } }
From source file:org.jenkins_ci.update_center.Main.java
/** * Build JSON for the plugin list.//w w w . j a va2s . c o m * * @param repository * @param redirect */ protected JSONObject buildPlugins(MavenRepository repository, PrintWriter redirect) throws Exception { SAXReader saxReader = createXmlReader(); ConfluencePluginList cpl = new ConfluencePluginList(); int total = 0; JSONObject plugins = new JSONObject(); for (PluginHistory hpi : repository.listHudsonPlugins()) { try { System.out.println(hpi.artifactId); List<HPI> versions = new ArrayList<HPI>(hpi.artifacts.values()); HPI latest = versions.get(0); latest.file = repository.resolve(latest.artifact); HPI previous = versions.size() > 1 ? versions.get(1) : null; if (previous != null) { previous.file = repository.resolve(previous.artifact); } Document pomDoc = null; Document parentPom = null; File pomFile = repository.resolvePOM(latest.artifact); if (pomFile != null) { pomDoc = readPOM(saxReader, pomFile); } if (pomDoc != null) { parentPom = resolveParentPom(repository, latest.artifact, saxReader, pomDoc); } RemotePage hpiWikiPage = findPage(hpi.artifactId, pomDoc, cpl); Plugin plugin = new Plugin(hpi.artifactId, latest, previous, pomDoc, parentPom, hpiWikiPage, readLabels(hpiWikiPage, cpl)); checkLatestDate(repository, versions, latest); if (plugin.isDeprecated()) { System.out.println("=> Plugin is deprecated.. skipping."); continue; } System.out.println(plugin.page != null ? "=> " + plugin.page.getTitle() : "** No wiki page found"); JSONObject json = plugin.toJSON(); System.out.println("=> " + json); plugins.put(plugin.artifactId, json); String permalink = String.format("/latest/%s.hpi", plugin.artifactId); redirect.printf("Redirect 302 %s %s\n", permalink, plugin.latest.getURL().getPath()); if (download != null) { for (HPI v : hpi.artifacts.values()) { stage(v, new File(download, "plugins/" + hpi.artifactId + "/" + v.version + "/" + hpi.artifactId + ".hpi")); } if (!hpi.artifacts.isEmpty()) { createLatestSymlink(hpi, plugin.latest); } } if (www != null) { buildIndex(new File(www, "download/plugins/" + hpi.artifactId), hpi.artifactId, hpi.artifacts.values(), permalink); } total++; } catch (IOException e) { e.printStackTrace(); // move on to the next plugin } } System.out.println("Total " + total + " plugins listed."); return plugins; }
From source file:edu.cornell.med.icb.goby.modes.CountsArchiveToWiggleMode.java
/** * Run the map2text mode.//from w ww . j a v a2 s .c om * * @throws java.io.IOException error reading / writing */ @Override public void execute() throws IOException { PrintWriter writer = null; try { writer = new PrintWriter( new GZIPOutputStream(new FastBufferedOutputStream(new FileOutputStream(outputFile + ".gz")))); writer.write("track type=wiggle_0 name=" + label + " visibility=full viewLimits=1:200\n"); final AlignmentReaderImpl alignment = new AlignmentReaderImpl(inputBasename); alignment.readHeader(); alignment.close(); final IndexedIdentifier referenceIds = alignment.getTargetIdentifiers(); final DoubleIndexedIdentifier backwards = new DoubleIndexedIdentifier(referenceIds); final CountsArchiveReader reader = new CountsArchiveReader(inputBasename, alternativeCountArchiveExtension); final WiggleWindow wiggleWindow = new WiggleWindow(writer, resolution, 0); for (int referenceIndex = 0; referenceIndex < reader.getNumberOfIndices(); referenceIndex++) { String referenceId = backwards.getId(referenceIndex).toString(); boolean processThisSequence = true; // prepare reference ID for UCSC genome browser. if ("MT".equalsIgnoreCase(referenceId)) { // patch chromosome name for UCSC genome browser: referenceId = "M"; } // ignore c22_H2, c5_H2, and other contigs but not things like chr1 (mm9) if (referenceId.startsWith("c") && !referenceId.startsWith("chr")) { processThisSequence = false; } // ignore NT_* if (referenceId.startsWith("NT_")) { processThisSequence = false; } if (filterByReferenceNames && !includeReferenceNames.contains(referenceId)) { processThisSequence = false; } if (processThisSequence) { // prepend the reference id with "chr" if it doesn't use that already final String chromosome; if (referenceId.startsWith("chr")) { chromosome = referenceId; } else { chromosome = "chr" + referenceId; } long sumCount = 0; int numCounts = 0; CountsReader counts = reader.getCountReader(referenceIndex); int lastLength = 0; int lastPosition = 0; while (counts.hasNextTransition()) { counts.nextTransition(); lastPosition = counts.getPosition(); lastLength = counts.getLength(); } final int maxWritePosition = (lastPosition + lastLength - 1); wiggleWindow.reset(); wiggleWindow.setMaxDataSize(maxWritePosition); writer.printf("variableStep chrom=%s span=%d\n", chromosome, resolution); counts = reader.getCountReader(referenceIndex); while (counts.hasNextTransition()) { counts.nextTransition(); final int length = counts.getLength(); final int count = counts.getCount(); final int position = counts.getPosition(); wiggleWindow.addData(position, length, count); sumCount += count; numCounts++; } wiggleWindow.finish(); final double averageCount = sumCount / (double) numCounts; System.out.println("average count for sequence " + referenceId + " " + averageCount); } } } finally { IOUtils.closeQuietly(writer); } }
From source file:pt.ist.fenixedu.contracts.tasks.giafsync.ImportTypesFromGiaf.java
@Override public void processChanges(GiafMetadata metadata, PrintWriter log, Logger logger) throws Exception { int updatedAccumulations = 0; int newAccumulations = 0; int updatedGrantOwnerEquivalences = 0; int newGrantOwnerEquivalences = 0; int updatedExemptions = 0; int newExemptions = 0; int updatedContractTypes = 0; int newContractTypes = 0; int updatedAbsences = 0; int newAbsences = 0; PersistentSuportGiaf oracleConnection = PersistentSuportGiaf.getInstance(); PreparedStatement preparedStatement = oracleConnection.prepareStatement(getQuery()); ResultSet result = preparedStatement.executeQuery(); while (result.next()) { String type = result.getString("TAB_NUM"); final String giafId = result.getString("tab_cod"); String nameString = result.getString("tab_cod_alg"); if (StringUtils.isEmpty(nameString)) { nameString = result.getString("tab_cod_dsc"); }/*from w w w. j av a2 s .c o m*/ final MultiLanguageString name = new MultiLanguageString(MultiLanguageString.pt, nameString); if (type.equalsIgnoreCase(FUNCTIONS_ACCUMULATION)) { FunctionsAccumulation accumulation = metadata.accumulation(giafId); if (accumulation != null) { if (!accumulation.getName().equalInAnyLanguage(name)) { accumulation.edit(name); updatedAccumulations++; } } else { metadata.registerAccumulation(giafId, name); newAccumulations++; } } else if (type.equalsIgnoreCase(GRANT_OWNER_EQUIVALENCE)) { GrantOwnerEquivalent grantOwnerEquivalent = metadata.grantOwnerEquivalent(giafId); if (grantOwnerEquivalent != null) { if (!grantOwnerEquivalent.getName().equalInAnyLanguage(name)) { grantOwnerEquivalent.edit(name); updatedGrantOwnerEquivalences++; } } else { metadata.registerGrantOwnerEquivalent(giafId, name); newGrantOwnerEquivalences++; } } else if (type.equalsIgnoreCase(SERVICE_EXEMPTION)) { ServiceExemption exemption = metadata.exemption(giafId); if (exemption != null) { if (!exemption.getName().equalInAnyLanguage(name)) { exemption.edit(name); updatedExemptions++; } } else { metadata.registerExemption(giafId, name); newExemptions++; } } else if (type.equalsIgnoreCase(CONTRACT_TYPE)) { ProfessionalContractType contractType = metadata.contractType(giafId); if (contractType != null) { if (!contractType.getName().equalInAnyLanguage(name)) { contractType.edit(name); updatedContractTypes++; } } else { metadata.registerContractType(giafId, name); newContractTypes++; } } else if (type.equalsIgnoreCase(ABSENCE_TYPE)) { Absence absence = metadata.absence(giafId); if (absence != null) { if (!absence.getName().equalInAnyLanguage(name)) { absence.edit(name); updatedAbsences++; } } else { metadata.registerAbsence(giafId, name); newAbsences++; } } } result.close(); preparedStatement.close(); oracleConnection.closeConnection(); log.printf("Accumulations: %d updated, %d new\n", updatedAccumulations, newAccumulations); log.printf("GrantOwnerEquivalences: %d updated, %d new\n", updatedGrantOwnerEquivalences, newGrantOwnerEquivalences); log.printf("Exemptions: %d updated, %d new\n", updatedExemptions, newExemptions); log.printf("ContractTypes: %d updated, %d new\n", updatedContractTypes, newContractTypes); log.printf("Absences: %d updated, %d new\n", updatedAbsences, newAbsences); }