static int checkAck(InputStream in) throws IOException { int b = in.read(); // b may be 0 for success, // 1 for error, // 2 for fatal error, // -1 if (b == 0) return b; if (b == -1) return b; if (b == 1 || b == 2) { StringBuffer sb = new StringBuffer(); int c; do { c = in.read(); sb.append((char) c); } while (c != '\n'); if (b == 1) { // error System.out.print(sb.toString()); } if (b == 2) { // fatal error System.out.print(sb.toString()); } } return b; }
protected String gettitle(String strFreq) { StringBuffer sbufTitle = new StringBuffer().append("VnmrJ "); String strPath = FileUtil.openPath(FileUtil.SYS_VNMR + "/vnmrrev"); BufferedReader reader = WFileUtil.openReadFile(strPath); String strLine; String strtype = ""; if (reader == null) return sbufTitle.toString(); try { while ((strLine = reader.readLine()) != null) { strtype = strLine; } strtype = strtype.trim(); if (strtype.equals("merc")) strtype = "Mercury"; else if (strtype.equals("mercvx")) strtype = "Mercury-Vx"; else if (strtype.equals("mercplus")) strtype = "MERCURY plus"; else if (strtype.equals("inova")) strtype = "INOVA"; String strHostName = m_strHostname; if (strHostName == null) strHostName = ""; sbufTitle.append(" ").append(strHostName); sbufTitle.append(" ").append(strtype); sbufTitle.append(" - ").append(strFreq); reader.close(); } catch (Exception e) { // e.printStackTrace(); Messages.logError(e.toString()); } return sbufTitle.toString(); }
/** * Create a Transferable to use as the source for a data transfer. * * @param c The component holding the data to be transfered. This argument is provided to enable * sharing of TransferHandlers by multiple components. * @return The representation of the data to be transfered. */ protected Transferable createTransferable(JComponent c) { Object[] values = null; if (c instanceof JList) { values = ((JList) c).getSelectedValues(); } else if (c instanceof JTable) { JTable table = (JTable) c; int[] rows = table.getSelectedRows(); if (rows != null) { values = new Object[rows.length]; for (int i = 0; i < rows.length; i++) { values[i] = table.getValueAt(rows[i], 0); } } } if (values == null || values.length == 0) { return null; } StringBuffer plainBuf = new StringBuffer(); StringBuffer htmlBuf = new StringBuffer(); htmlBuf.append("<html>\n<body>\n<ul>\n"); for (Object obj : values) { String val = ((obj == null) ? "" : obj.toString()); plainBuf.append(val + "\n"); htmlBuf.append(" <li>" + val + "\n"); } // remove the last newline plainBuf.deleteCharAt(plainBuf.length() - 1); htmlBuf.append("</ul>\n</body>\n</html>"); return new FileTransferable(plainBuf.toString(), htmlBuf.toString(), values); }
/** * Adds the matching block end. * * @param offset the offset * @return the string after adding the matching block end * @throws BadLocationException if the offset is invalid */ protected String addMatchingBlockEnd(int offset) throws BadLocationException { StringBuffer result; StringBuffer whiteSpace = new StringBuffer(); int line = m_RootElement.getElementIndex(offset); int i = m_RootElement.getElement(line).getStartOffset(); while (true) { String temp = m_Self.getText(i, 1); if (temp.equals(" ") || temp.equals("\t")) { whiteSpace.append(temp); i++; } else { break; } } // assemble string result = new StringBuffer(); result.append(m_BlockStart); result.append("\n"); result.append(whiteSpace.toString()); if (m_UseBlanks) result.append(m_Indentation); else result.append("\t"); result.append("\n"); result.append(whiteSpace.toString()); result.append(m_BlockEnd); return result.toString(); }
/** * Send a message to the client * * @return true if message is not empty */ public boolean sendMessage() { if (messageToSend.length() == 0) return false; client.sendMessage(messageToSend.toString()); addMessageToLog("You: " + messageToSend.toString()); messageToSend.delete(0, messageToSend.length()); return true; }
public void addDataSet(Color color, String legend, Data data[]) throws Exception { /* init */ this._initChart(); /* dataset color/legend/markers */ String hexColor = ColorTools.toHexString(color, false); this.addDatasetColor(hexColor); this.addDatasetLegend(legend); this.addShapeMarker("d," + hexColor + "," + this.dataSetCount + ",-1,7,1"); /* data */ StringBuffer xv = new StringBuffer(); StringBuffer yv = new StringBuffer(); for (int i = 0; i < data.length; i++) { GetScaledExtendedEncodedValue(yv, data[i].getTempC(), this.minTempC, this.maxTempC); GetScaledExtendedEncodedValue(xv, data[i].getTimestamp(), this.minDateTS, this.maxDateTS); } if (StringTools.isBlank(this.chd)) { this.chd = "e:"; } else { this.chd += ","; } this.chd += xv.toString() + "," + yv.toString(); /* count data set */ this.dataSetCount++; }
private void setCoordsText(final Coord[] coords, String description) { StringBuffer linebuf; Coord vertex; YaxisTreeNode node; TreeNode[] nodes; Integer lineID; double duration; int coords_length; int idx, ii; linebuf = new StringBuffer(); coords_length = coords.length; if (coords_length > 1) { duration = coords[coords_length - 1].time - coords[0].time; linebuf.append("duration" + description + " = " + tfmt.format(duration)); if (num_cols < linebuf.length()) num_cols = linebuf.length(); num_rows++; strbuf.append(linebuf.toString() + "\n"); } for (idx = 0; idx < coords_length; idx++) { linebuf = new StringBuffer("[" + idx + "]: "); vertex = coords[idx]; lineID = new Integer(vertex.lineID); node = (YaxisTreeNode) map_line2treenodes.get(lineID); nodes = node.getPath(); linebuf.append("time" + description + " = " + fmt.format(vertex.time)); for (ii = 1; ii < nodes.length; ii++) linebuf.append(", " + y_colnames[ii - 1] + " = " + nodes[ii]); if (num_cols < linebuf.length()) num_cols = linebuf.length(); num_rows++; strbuf.append(linebuf.toString()); if (idx < coords_length - 1) strbuf.append("\n"); } }
private void outdentText(JTextComponent textComponent) throws BadLocationException { int tabSize = ((Integer) textComponent.getDocument().getProperty(PlainDocument.tabSizeAttribute)) .intValue(); String selectedText = textComponent.getSelectedText(); int newLineIndex = selectedText != null ? selectedText.indexOf('\n') : -1; if (newLineIndex >= 0) { int originalSelectionStart = textComponent.getSelectionStart(); int selectionStart = originalSelectionStart; int selectionEnd = textComponent.getSelectionEnd(); int lastNewLineBeforeSelection = textComponent.getText(0, selectionStart).lastIndexOf('\n'); int begin = lastNewLineBeforeSelection >= 0 ? lastNewLineBeforeSelection : 0; int end = selectionEnd; String text = textComponent.getText(begin, end - begin); if (lastNewLineBeforeSelection < 0) { text = "\n" + text; } int len = text.length(); StringBuffer out = new StringBuffer(len); for (int i = 0; i < len; i++) { char ch = text.charAt(i); out.append(ch); if (ch == '\n' && i < len - 1) { char next = text.charAt(i + 1); int stripCount = 0; if (next == '\t') { stripCount = 1; } else { for (; stripCount < tabSize && i + 1 + stripCount < len; stripCount++) { next = text.charAt(i + 1 + stripCount); if (next != ' ' && next != '\t') { break; } } } selectionEnd -= stripCount; if (i + begin < originalSelectionStart - 1) { selectionStart -= stripCount; } i += stripCount; } } textComponent.select(begin, end); textComponent.replaceSelection( lastNewLineBeforeSelection < 0 ? out.toString().substring(1) : out.toString()); textComponent.select(selectionStart, selectionEnd); } }
String toBinary(int n) { if (n == 0) { return ("0"); } StringBuffer binary = new StringBuffer(); while (n > 0) { int rem = n % 2; binary = new StringBuffer(rem + binary.toString()); n = n / 2; } while (binary.length() < 8) { binary.insert(0, "0"); } return binary.toString(); }
/** * Output the specified {@link Collection} in proper columns. * * @param stuff the stuff to print */ public void printColumns(final Collection stuff) throws IOException { if ((stuff == null) || (stuff.size() == 0)) { return; } int width = getTermwidth(); int maxwidth = 0; for (Iterator i = stuff.iterator(); i.hasNext(); maxwidth = Math.max(maxwidth, i.next().toString().length())) {; } StringBuffer line = new StringBuffer(); int showLines; if (usePagination) showLines = getTermheight() - 1; // page limit else showLines = Integer.MAX_VALUE; for (Iterator i = stuff.iterator(); i.hasNext(); ) { String cur = (String) i.next(); if ((line.length() + maxwidth) > width) { printString(line.toString().trim()); printNewline(); line.setLength(0); if (--showLines == 0) { // Overflow printString(loc.getString("display-more")); flushConsole(); int c = readVirtualKey(); if (c == '\r' || c == '\n') showLines = 1; // one step forward else if (c != 'q') showLines = getTermheight() - 1; // page forward back(loc.getString("display-more").length()); if (c == 'q') break; // cancel } } pad(cur, maxwidth + 3, line); } if (line.length() > 0) { printString(line.toString().trim()); printNewline(); line.setLength(0); } }
@FXML private void handleExportItemAction(ActionEvent event) { try { BufferedWriter bw = new BufferedWriter( new OutputStreamWriter(new FileOutputStream("imageInformation.csv"), "UTF-8")); for (ImageInformation img : imgMan.images) { StringBuffer oneLine = new StringBuffer(); oneLine.append(img.getPath()); oneLine.append(";"); for (Point p : img.getPoints()) { oneLine.append(p.getX() + "," + p.getY()); } oneLine.append(";"); for (ImageInformation.Type t : img.getTypes()) { oneLine.append(t.toString()); } oneLine.append(";"); for (double d : img.getFrequency()) { oneLine.append(d + ","); } oneLine.append(";"); bw.write(oneLine.toString()); bw.newLine(); } bw.flush(); bw.close(); } catch (UnsupportedEncodingException e) { } catch (FileNotFoundException e) { } catch (IOException e) { } }
private void processKey(char c) { if (c == '\n') { AppUser user = null; try { user = m_dlSystem.findPeopleByCard(inputtext.toString()); } catch (BasicException e) { e.printStackTrace(); } if (user == null) { // user not found MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.nocard")); msg.show(this); } else { openAppView(user); } inputtext = new StringBuffer(); } else { inputtext.append(c); } }
public String toString() { StringBuffer st = new StringBuffer(); st.append(" Cut Panels: "); for (int i = 0; i < visibleViewIds.size(); i++) { st.append(" " + Constants.cpNames[((Integer) visibleViewIds.elementAt(i)).intValue()]); } st.append(" \nCutPanelSize: "); st.append(cutPanelSize); st.append(" \nlonReference: "); st.append(lonReference); st.append(" \ngeoDisplayFormat: "); st.append(geoDisplayFormat); st.append(" \nuseCenterWidthOrMinMax: "); st.append(useCenterWidthOrMinMax); st.append(" \ntimeDisplayFormat: "); st.append(timeDisplayFormat); st.append(" \ntimeAxisMode: "); st.append(timeAxisMode); st.append(" \ntimeAxisReference: "); st.append(timeAxisReference); st.append(" \ntimeSinceUnits: "); st.append(timeSinceUnits); st.append(" \ndisplayPanelAxes: "); st.append(displayPanelAxes); st.append(" \nindependentHandles: "); st.append(independentHandles); return st.toString(); }
public Properties internalToProperties() { Properties props = new Properties(); StringBuffer st = new StringBuffer(); st.append(" "); for (int i = 0; i < visibleViewIds.size(); i++) { st.append(" " + Constants.cpNames[((Integer) visibleViewIds.elementAt(i)).intValue()]); } // System.out.println(" visibleViewIds: " + st.toString()); props.setProperty("ndedit.visibleViewIds", st.toString()); props.setProperty("ndedit.cutPanelSizeW", (new Integer(cutPanelSize.width).toString())); props.setProperty("ndedit.cutPanelSizeH", (new Integer(cutPanelSize.height).toString())); props.setProperty("ndedit.cutPanelWMin", (new Integer(cutPanelMinSize.width).toString())); props.setProperty("ndedit.cutPanelHMin", (new Integer(cutPanelMinSize.height).toString())); props.setProperty("ndedit.cutPanelWMax", (new Integer(cutPanelMaxSize.width).toString())); props.setProperty("ndedit.cutPanelHMax", (new Integer(cutPanelMaxSize.height).toString())); props.setProperty("ndedit.lonReference", (new Double(lonReference).toString())); props.setProperty("ndedit.geoDisplayFormat", (new Integer(geoDisplayFormat).toString())); props.setProperty("ndedit.timeDisplayFormat", (new Integer(timeDisplayFormat).toString())); props.setProperty("ndedit.timeAxisMode", (new Integer(timeAxisMode).toString())); props.setProperty("ndedit.timeAxisReference", (new Double(timeAxisReference).toString())); String dpa = new Boolean(displayPanelAxes).toString(); props.setProperty("ndedit.displayPanelAxes", dpa); dpa = new Boolean(independentHandles).toString(); props.setProperty("ndedit.independentHandles", dpa); return props; }
/** * @return the clipboard content as a String (DataFlavor.stringFlavor) Code snippet adapted from * jEdit (Registers.java), http://www.jedit.org. Returns null if clipboard is empty. */ public static String getClipboardStringContent(Clipboard clipboard) { // Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); try { String selection = (String) (clipboard.getContents(null).getTransferData(DataFlavor.stringFlavor)); if (selection == null) return null; boolean trailingEOL = (selection.endsWith("\n") || selection.endsWith(System.getProperty("line.separator"))); // Some Java versions return the clipboard contents using the native line separator, // so have to convert it here , see jEdit's "registers.java" BufferedReader in = new BufferedReader(new StringReader(selection)); StringBuffer buf = new StringBuffer(); String line; while ((line = in.readLine()) != null) { buf.append(line); buf.append('\n'); } // remove trailing \n if (!trailingEOL) buf.setLength(buf.length() - 1); return buf.toString(); } catch (Exception e) { e.printStackTrace(); return null; } }
private Pattern getCurrentPattern() { String pattern = getFindTextField().getText(); int flags = Pattern.DOTALL; if (!getRegexButton().isSelected()) { StringBuffer newpattern = new StringBuffer(); // 'quote' the pattern for (int i = 0; i < pattern.length(); i++) { if ("\\[]^$&|().*+?{}".indexOf(pattern.charAt(i)) >= 0) { newpattern.append('\\'); } newpattern.append(pattern.charAt(i)); } pattern = newpattern.toString(); // make "*" .* and "?" . if (getWildCardsButton().isSelected()) { pattern = pattern.replaceAll("\\\\\\*", ".+?"); pattern = pattern.replaceAll("\\\\\\?", "."); } } if (!getCaseSensitiveCheckBox().isSelected()) { flags |= Pattern.CASE_INSENSITIVE; } if (getWholeWordCheckBox().isSelected()) { pattern = "\\b" + pattern + "\\b"; } return Pattern.compile(pattern, flags); }
/** * Check if the server is ok * * @return status code */ protected int checkIfServerIsOk() { try { StringBuffer buff = getUrl(REQ_TEXT); appendKeyValue(buff, PROP_FILE, FILE_PUBLICSRV); URL url = new URL(buff.toString()); URLConnection urlc = url.openConnection(); InputStream is = urlc.getInputStream(); is.close(); return STATUS_OK; } catch (AddeURLException ae) { String aes = ae.toString(); if (aes.indexOf("Invalid project number") >= 0) { LogUtil.userErrorMessage("Invalid project number"); return STATUS_NEEDSLOGIN; } if (aes.indexOf("Invalid user id") >= 0) { LogUtil.userErrorMessage("Invalid user ID"); return STATUS_NEEDSLOGIN; } if (aes.indexOf("Accounting data") >= 0) { return STATUS_NEEDSLOGIN; } if (aes.indexOf("cannot run server 'txtgserv") >= 0) { return STATUS_OK; } LogUtil.userErrorMessage("Error connecting to server. " + ae.getMessage()); return STATUS_ERROR; } catch (Exception exc) { logException("Connecting to server:" + getServer(), exc); return STATUS_ERROR; } }
public String nextToken() { StringBuffer token = new StringBuffer(); while (skipChar((char) getChar(1))) { nextChar(); } while (nextChar()) { char c = getChar(); if (c == '"') { token.append(parseString()); break; } if (isWordChar(c)) { token.append(c); } else { if (token.length() == 0) token.append(c); else position--; break; } } if (token.length() == 0) return null; else return token.toString(); }
public boolean shutdown(int port, boolean ssl) { try { String protocol = "http" + (ssl ? "s" : ""); URL url = new URL(protocol, "127.0.0.1", port, "shutdown"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setRequestProperty("servicemanager", "shutdown"); conn.connect(); StringBuffer sb = new StringBuffer(); BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8")); int n; char[] cbuf = new char[1024]; while ((n = br.read(cbuf, 0, cbuf.length)) != -1) sb.append(cbuf, 0, n); br.close(); String message = sb.toString().replace("<br>", "\n"); if (message.contains("Goodbye")) { cp.appendln("Shutting down the server:"); String[] lines = message.split("\n"); for (String line : lines) { cp.append("..."); cp.appendln(line); } return true; } } catch (Exception ex) { } cp.appendln("Unable to shutdown CTP"); return false; }
@Override public Operation buildOperation( Map<String, String> parameterMap, InputStream artifactStream, String mimeType) { String key = FilterTypeEnum.CROP.toString().toLowerCase(); if (!containsMyFilterParams(key, parameterMap)) { return null; } Operation operation = new Operation(); operation.setName(key); String factor = parameterMap.get(key + "-factor"); operation.setFactor(factor == null ? null : Double.valueOf(factor)); UnmarshalledParameter rectangle = new UnmarshalledParameter(); String rectangleApplyFactor = parameterMap.get(key + "-apply-factor"); rectangle.setApplyFactor( rectangleApplyFactor == null ? false : Boolean.valueOf(rectangleApplyFactor)); rectangle.setName("rectangle"); rectangle.setType(ParameterTypeEnum.RECTANGLE.toString()); StringBuffer sb = new StringBuffer(); sb.append(parameterMap.get(key + "-x-amount")); sb.append(","); sb.append(parameterMap.get(key + "-y-amount")); sb.append(","); sb.append(parameterMap.get(key + "-width-amount")); sb.append(","); sb.append(parameterMap.get(key + "-height-amount")); rectangle.setValue(sb.toString()); operation.setParameters(new UnmarshalledParameter[] {rectangle}); return operation; }
/** Add import statements to the current tab for all of packages inside the specified jar file. */ public void handleImportLibrary(String jarPath) { // make sure the user didn't hide the sketch folder sketch.ensureExistence(); // import statements into the main sketch file (code[0]) // if the current code is a .java file, insert into current // if (current.flavor == PDE) { if (mode.isDefaultExtension(sketch.getCurrentCode())) { sketch.setCurrentCode(0); } // could also scan the text in the file to see if each import // statement is already in there, but if the user has the import // commented out, then this will be a problem. String[] list = Base.packageListFromClassPath(jarPath); StringBuffer buffer = new StringBuffer(); for (int i = 0; i < list.length; i++) { buffer.append("import "); buffer.append(list[i]); buffer.append(".*;\n"); } buffer.append('\n'); buffer.append(getText()); setText(buffer.toString()); setSelection(0, 0); // scroll to start sketch.setModified(true); }
private static double readDouble(PushbackReader read) throws IOException { StringBuffer s = new StringBuffer(); int count = -1; while (true) { char ch = (char) read.read(); // skip spaces if (ch == ' ') continue; count++; // allow a - only if at the beginning if (ch == '-' && count == 0) { // u.p("negative number"); s.append(ch); continue; } if ((ch >= '0' && ch <= '9') || ch == '.') { // u.p("got double part " + ch); s.append(ch); } else { if (ch != ',') { read.unread(ch); } break; } } return Double.parseDouble(s.toString()); }
String[] getContactList() { java.util.List cl = new java.util.LinkedList(); StringTokenizer st = new StringTokenizer(contactList.getText()); StringBuffer sb = new StringBuffer(); StringBuffer dbg = new StringBuffer("test applet contactlist: "); while (st.hasMoreTokens()) { String loginId = st.nextToken().trim(); if (loginId.length() == 0) continue; dbg.append("'" + loginId + "' "); cl.add(loginId); sb.append(loginId).append('\n'); } CAT.info(dbg.toString()); contactList.setText(sb.toString()); return (String[]) cl.toArray(new String[cl.size()]); }
/** * Get the <code>String</code> that represents this <code>MetSymbol</code>. * * @return <code>String</code> representation. */ public String toString() { StringBuffer sb = new StringBuffer(super.toString()); for (String s : paramIds) { sb.append(" param:" + s); } return sb.toString(); }
/** * Get the Lincese text from a text file specified in the PropertyBox. * * @return String - License text. */ public String getLicenseText() { StringBuffer textBuffer = new StringBuffer(); try { String fileName = RuntimeProperties.GPL_EN_LICENSE_FILE_NAME; if (cbLang != null && cbLang.getSelectedItem() != null && cbLang.getSelectedItem().toString().equalsIgnoreCase("Eesti")) { fileName = RuntimeProperties.GPL_EE_LICENSE_FILE_NAME; } InputStream is = this.getClass().getClassLoader().getResourceAsStream(fileName); if (is == null) return ""; BufferedReader in = new BufferedReader(new InputStreamReader(is)); String str; while ((str = in.readLine()) != null) { textBuffer.append(str); textBuffer.append("\n"); } in.close(); } catch (IOException e) { logger.error(null, e); } return textBuffer.toString(); } // getLicenseText
public void doActionOnButton3() { // Sector sector = Sector.fromDegrees( 44d, 46d, -123.3d, -123.2d ); ArrayList<LatLon> latlons = new ArrayList<LatLon>(); latlons.add(LatLon.fromDegrees(45.50d, -123.3d)); // latlons.add( LatLon.fromDegrees( 45.51d, -123.3d ) ); latlons.add(LatLon.fromDegrees(45.52d, -123.3d)); // latlons.add( LatLon.fromDegrees( 45.53d, -123.3d ) ); latlons.add(LatLon.fromDegrees(45.54d, -123.3d)); // latlons.add( LatLon.fromDegrees( 45.55d, -123.3d ) ); latlons.add(LatLon.fromDegrees(45.56d, -123.3d)); // latlons.add( LatLon.fromDegrees( 45.57d, -123.3d ) ); latlons.add(LatLon.fromDegrees(45.58d, -123.3d)); // latlons.add( LatLon.fromDegrees( 45.59d, -123.3d ) ); latlons.add(LatLon.fromDegrees(45.60d, -123.3d)); ElevationModel model = this.wwd.getModel().getGlobe().getElevationModel(); StringBuffer sb = new StringBuffer(); for (LatLon ll : latlons) { double e = model.getElevation(ll.getLatitude(), ll.getLongitude()); sb.append("\n").append(e); } Logging.logger().info(sb.toString()); }
public GElement generateGraph(String dotFile) throws IOException { BufferedReader br = new BufferedReader(new FileReader(dotFile)); graph = null; /** * The problem here is that DOT sometime inserts a '\' at the end of a long line so we have to * skip it and continue to parse until a "real" EOL is reached. Example: statement -> * compoundStatement [pos="e,3264,507 3271,2417 3293,2392 ... 3237,565 3234,560 32\ 39,545 * 3243,534 3249,523 3257,514"]; */ StringBuffer line = new StringBuffer(); int c; // current character int pc = -1; // previous character while ((c = br.read()) != -1) { if (c == '\n') { if (pc == '\\') { // Remove the last \ if it was part of the DOT wrapping character line.deleteCharAt(line.length() - 1); } else { GElement element = parseLine(line.toString()); if (element != null) { if (graph == null) graph = element; else graph.addElement(element); } line.delete(0, line.length()); } } else if (c != '\r') { line.append((char) c); } pc = c; } return graph; }
/** * format a given Font to a string, following "Font.decode()" format, ie fontname-style-pointsize, * fontname-pointsize, fontname-style or fontname, where style is one of "BOLD", "ITALIC", * "BOLDITALIC" (default being PLAIN) */ public static String formatFontAsProperties(Font font) { // jpicedt.Log.debug(new MiscUtilities(),"formatFontAsProperties","font="+font); String family = font.getFamily(); /* System.out.println("family="+family); String faceName = font.getFontName(); System.out.println("faceName="+faceName); String logicalName = font.getName(); System.out.println("logicalName"+logicalName); String psName = font.getPSName(); System.out.println("PSName="+psName); */ StringBuffer buf = new StringBuffer(20); buf.append(family); buf.append("-"); switch (font.getStyle()) { case Font.ITALIC: buf.append("ITALIC-"); break; case Font.BOLD: buf.append("BOLD-"); break; case Font.BOLD | Font.ITALIC: buf.append("BOLDITALIC-"); break; default: // PLAIN -> nothing } buf.append(Integer.toString(font.getSize())); return buf.toString(); }
protected void setToolTip() { TileI currentTile = orUIManager.getGameUIManager().getGameManager().getTileManager().getTile(internalId); StringBuffer tt = new StringBuffer("<html>"); tt.append("<b>Tile</b>: ").append(currentTile.getName()); // or // getId() if (currentTile.hasStations()) { // for (Station st : currentTile.getStations()) int cityNumber = 0; // TileI has stations, but for (Station st : currentTile.getStations()) { cityNumber++; // = city.getNumber(); tt.append("<br> ") .append(st.getType()) .append(" ") .append(cityNumber) // .append("/").append(st.getNumber()) .append(": value "); tt.append(st.getValue()); if (st.getBaseSlots() > 0) { tt.append(", ").append(st.getBaseSlots()).append(" slots"); } } } tt.append("</html>"); toolTip = tt.toString(); }
private String generateHTML(final RefEntity refEntity, final InspectionTool tool) { final StringBuffer buf = new StringBuffer(); if (refEntity instanceof RefElement) { final Runnable action = new Runnable() { @Override public void run() { tool.getComposer().compose(buf, refEntity); } }; ApplicationManager.getApplication().runReadAction(action); } else { tool.getComposer().compose(buf, refEntity); } uppercaseFirstLetter(buf); if (refEntity instanceof RefElement) { appendSuppressSection(buf); } insertHeaderFooter(buf); return buf.toString(); }