當前位置: 首頁>>代碼示例>>Java>>正文


Java StringUtil類代碼示例

本文整理匯總了Java中com.cburch.logisim.util.StringUtil的典型用法代碼示例。如果您正苦於以下問題:Java StringUtil類的具體用法?Java StringUtil怎麽用?Java StringUtil使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


StringUtil類屬於com.cburch.logisim.util包,在下文中一共展示了StringUtil類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: paintInstance

import com.cburch.logisim.util.StringUtil; //導入依賴的package包/類
@Override
public void paintInstance(InstancePainter painter) {
	painter.drawRoundBounds(Color.WHITE);
	painter.drawClock(0, Direction.EAST); // draw a triangle on port 0
	painter.drawPort(1); // draw port 1 as just a dot

	// Display the current counter value centered within the rectangle.
	// However, if the context says not to show state (as when generating
	// printer output), then skip this.
	if (painter.getShowState()) {
		CounterData state = CounterData.get(painter, BIT_WIDTH);
		Bounds bds = painter.getBounds();
		GraphicsUtil.drawCenteredText(painter.getGraphics(),
				StringUtil.toHexString(BIT_WIDTH.getWidth(), state.getValue().toIntValue()),
				bds.getX() + bds.getWidth() / 2, bds.getY() + bds.getHeight() / 2);
	}
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:18,代碼來源:SimpleGrayCounter.java

示例2: paintInstance

import com.cburch.logisim.util.StringUtil; //導入依賴的package包/類
@Override
public void paintInstance(InstancePainter painter) {
	// This is essentially the same as with SimpleGrayCounter, except for
	// the invocation of painter.drawLabel to make the label be drawn.
	painter.drawRoundBounds(Color.WHITE);
	painter.drawClock(0, Direction.EAST);
	painter.drawPort(1);
	painter.drawLabel();

	if (painter.getShowState()) {
		BitWidth width = painter.getAttributeValue(StdAttr.WIDTH);
		CounterData state = CounterData.get(painter, width);
		Bounds bds = painter.getBounds();
		GraphicsUtil.drawCenteredText(painter.getGraphics(),
				StringUtil.toHexString(width.getWidth(), state.getValue().toIntValue()),
				bds.getX() + bds.getWidth() / 2, bds.getY() + bds.getHeight() / 2);
	}
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:19,代碼來源:GrayCounter.java

示例3: fromTool

import com.cburch.logisim.util.StringUtil; //導入依賴的package包/類
Element fromTool(Tool tool) {
	Library lib = findLibrary(tool);
	String lib_name;
	if (lib == null) {
		loader.showError(StringUtil.format("tool `%s' not found", tool.getDisplayName()));
		return null;
	} else if (lib == file) {
		lib_name = null;
	} else {
		lib_name = libs.get(lib);
		if (lib_name == null) {
			loader.showError("unknown library within file");
			return null;
		}
	}

	Element elt = doc.createElement("tool");
	if (lib_name != null)
		elt.setAttribute("lib", lib_name);
	elt.setAttribute("name", tool.getName());
	addAttributeSetContent(elt, tool.getAttributeSet(), tool);
	return elt;
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:24,代碼來源:XmlWriter.java

示例4: loadLogisimFile

import com.cburch.logisim.util.StringUtil; //導入依賴的package包/類
LogisimFile loadLogisimFile(File request) throws LoadFailedException {
	File actual = getSubstitution(request);
	for (File fileOpening : filesOpening) {
		if (fileOpening.equals(actual)) {
			throw new LoadFailedException(
					StringUtil.format(Strings.get("logisimCircularError"), toProjectName(actual)));
		}
	}

	LogisimFile ret = null;
	filesOpening.push(actual);
	try {
		ret = LogisimFile.load(actual, this);
	} catch (IOException e) {
		throw new LoadFailedException(
				StringUtil.format(Strings.get("logisimLoadError"), toProjectName(actual), e.toString()));
	} finally {
		filesOpening.pop();
	}
	ret.setName(toProjectName(actual));
	return ret;
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:23,代碼來源:Loader.java

示例5: getDescription

import com.cburch.logisim.util.StringUtil; //導入依賴的package包/類
@Override
public String getDescription() {
	String ret;
	FactoryDescription desc = description;
	if (desc != null) {
		ret = desc.getToolTip();
	} else {
		ComponentFactory source = getFactory();
		if (source != null) {
			ret = (String) source.getFeature(ComponentFactory.TOOL_TIP, getAttributeSet());
		} else {
			ret = null;
		}
	}
	if (ret == null) {
		ret = StringUtil.format(Strings.get("addToolText"), getDisplayName());
	}
	return ret;
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:20,代碼來源:AddTool.java

示例6: confirmClose

import com.cburch.logisim.util.StringUtil; //導入依賴的package包/類
public boolean confirmClose(String title) {
	String message = StringUtil.format(Strings.get("confirmDiscardMessage"), proj.getLogisimFile().getName());

	if (!proj.isFileDirty())
		return true;
	toFront();
	String[] options = { Strings.get("saveOption"), Strings.get("discardOption"), Strings.get("cancelOption") };
	int result = JOptionPane.showOptionDialog(this, message, title, 0, JOptionPane.QUESTION_MESSAGE, null, options,
			options[0]);
	boolean ret;
	if (result == 0) {
		ret = ProjectActions.doSave(proj);
	} else if (result == 1) {
		ret = true;
	} else {
		ret = false;
	}
	if (ret) {
		dispose();
	}
	return ret;
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:23,代碼來源:Frame.java

示例7: printUsage

import com.cburch.logisim.util.StringUtil; //導入依賴的package包/類
private static void printUsage() {
	System.err.println(StringUtil.format(Strings.get("argUsage"), Startup.class.getName())); // OK
	System.err.println(); // OK
	System.err.println(Strings.get("argOptionHeader")); // OK
	System.err.println("   " + Strings.get("argAccentsOption")); // OK
	System.err.println("   " + Strings.get("argClearOption")); // OK
	System.err.println("   " + Strings.get("argEmptyOption")); // OK
	System.err.println("   " + Strings.get("argGatesOption")); // OK
	System.err.println("   " + Strings.get("argHelpOption")); // OK
	System.err.println("   " + Strings.get("argLoadOption")); // OK
	System.err.println("   " + Strings.get("argLocaleOption")); // OK
	System.err.println("   " + Strings.get("argNoSplashOption")); // OK
	System.err.println("   " + Strings.get("argPlainOption")); // OK
	System.err.println("   " + Strings.get("argSubOption")); // OK
	System.err.println("   " + Strings.get("argTemplateOption")); // OK
	System.err.println("   " + Strings.get("argTtyOption")); // OK
	System.err.println("   " + Strings.get("argVersionOption")); // OK
	System.exit(-1);
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:20,代碼來源:Startup.java

示例8: displaySpeed

import com.cburch.logisim.util.StringUtil; //導入依賴的package包/類
private static void displaySpeed(long tickCount, long elapse) {
	double hertz = (double) tickCount / elapse * 1000.0;
	double precision;
	if (hertz >= 100)
		precision = 1.0;
	else if (hertz >= 10)
		precision = 0.1;
	else if (hertz >= 1)
		precision = 0.01;
	else if (hertz >= 0.01)
		precision = 0.0001;
	else
		precision = 0.0000001;
	hertz = (int) (hertz / precision) * precision;
	String hertzStr = hertz == (int) hertz ? "" + (int) hertz : "" + hertz;
	System.out.println(StringUtil.format(Strings.get("ttySpeedMsg"), // OK
			hertzStr, "" + tickCount, "" + elapse));
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:19,代碼來源:TtyInterface.java

示例9: paintInstance

import com.cburch.logisim.util.StringUtil; //導入依賴的package包/類
@Override
public void paintInstance(InstancePainter painter) {
	painter.drawBounds();
	painter.drawClock(0, Direction.EAST); // draw a triangle on port 0
	painter.drawPort(1); // draw port 1 as just a dot

	// Display the current counter value centered within the rectangle.
	// However, if the context says not to show state (as when generating
	// printer output), then skip this.
	if (painter.getShowState()) {
		CounterData state = CounterData.get(painter, BIT_WIDTH);
		Bounds bds = painter.getBounds();
		GraphicsUtil.drawCenteredText(painter.getGraphics(), StringUtil
				.toHexString(BIT_WIDTH.getWidth(), state.getValue()
						.toIntValue()), bds.getX() + bds.getWidth() / 2,
				bds.getY() + bds.getHeight() / 2);
	}
}
 
開發者ID:reds-heig,項目名稱:logisim-evolution,代碼行數:19,代碼來源:SimpleGrayCounter.java

示例10: getDescription

import com.cburch.logisim.util.StringUtil; //導入依賴的package包/類
@Override
public String getDescription() {
	String ret;
	FactoryDescription desc = description;
	if (desc != null) {
		ret = desc.getToolTip();
	} else {
		ComponentFactory source = getFactory();
		if (source != null) {
			ret = (String) source.getFeature(ComponentFactory.TOOL_TIP,
					getAttributeSet());
		} else {
			ret = null;
		}
	}
	if (ret == null) {
		ret = StringUtil.format(Strings.get("addToolText"), getDisplayName());
	}
	return ret;
}
 
開發者ID:franciscaconcha,項目名稱:ProyectoLogisim,代碼行數:21,代碼來源:AddTool.java

示例11: parse

import com.cburch.logisim.util.StringUtil; //導入依賴的package包/類
@Override
public Integer parse(String value) {
	try {
		Integer ret = Integer.valueOf(value);
		if (ret.intValue() < min) {
			throw new NumberFormatException(StringUtil.format(
					Strings.get("durationSmallMessage"), "" + min));
		} else if (ret.intValue() > max) {
			throw new NumberFormatException(StringUtil.format(
					Strings.get("durationLargeMessage"), "" + max));
		}
		return ret;
	} catch (NumberFormatException e) {
		throw new NumberFormatException(Strings.get("freqInvalidMessage"));
	}
}
 
開發者ID:reds-heig,項目名稱:logisim-evolution,代碼行數:17,代碼來源:DurationAttribute.java

示例12: toDisplayString

import com.cburch.logisim.util.StringUtil; //導入依賴的package包/類
@Override
public String toDisplayString(Integer value) {
	if (TickUnits) {
		if (value.equals(Integer.valueOf(1))) {
			return Strings.get("clockDurationOneValue");
		} else {
			return StringUtil.format(Strings.get("clockDurationValue"),
					value.toString());
		}
	} else  {
		if (value.equals(Integer.valueOf(1))) {
			return Strings.get("PORDurationOneValue");
		} else {
			return StringUtil.format(Strings.get("PORDurationValue"),
					value.toString());
		}
	}
}
 
開發者ID:reds-heig,項目名稱:logisim-evolution,代碼行數:19,代碼來源:DurationAttribute.java

示例13: fromTool

import com.cburch.logisim.util.StringUtil; //導入依賴的package包/類
Element fromTool(Tool tool) {
	Library lib = findLibrary(tool);
	String lib_name;
	if (lib == null) {
		loader.showError(StringUtil.format("tool `%s' not found",
				tool.getDisplayName()));
		return null;
	} else if (lib == file) {
		lib_name = null;
	} else {
		lib_name = libs.get(lib);
		if (lib_name == null) {
			loader.showError("unknown library within file");
			return null;
		}
	}

	Element elt = doc.createElement("tool");
	if (lib_name != null)
		elt.setAttribute("lib", lib_name);
	elt.setAttribute("name", tool.getName());
	addAttributeSetContent(elt, tool.getAttributeSet(), tool);
	return elt;
}
 
開發者ID:reds-heig,項目名稱:logisim-evolution,代碼行數:25,代碼來源:XmlWriter.java

示例14: getFileFor

import com.cburch.logisim.util.StringUtil; //導入依賴的package包/類
File getFileFor(String name, FileFilter filter) {
	// Determine the actual file name.
	File file = new File(name);
	if (!file.isAbsolute()) {
		File currentDirectory = getCurrentDirectory();
		if (currentDirectory != null)
			file = new File(currentDirectory, name);
	}
	while (!file.canRead()) {
		// It doesn't exist. Figure it out from the user.
		JOptionPane.showMessageDialog(parent, StringUtil.format(
				Strings.get("fileLibraryMissingError"), file.getName()));
		JFileChooser chooser = createChooser();
		chooser.setFileFilter(filter);
		chooser.setDialogTitle(StringUtil.format(
				Strings.get("fileLibraryMissingTitle"), file.getName()));
		int action = chooser.showDialog(parent,
				Strings.get("fileLibraryMissingButton"));
		if (action != JFileChooser.APPROVE_OPTION) {
			throw new LoaderException(Strings.get("fileLoadCanceledError"));
		}
		file = chooser.getSelectedFile();
	}
	return file;
}
 
開發者ID:reds-heig,項目名稱:logisim-evolution,代碼行數:26,代碼來源:Loader.java

示例15: loadLogisimFile

import com.cburch.logisim.util.StringUtil; //導入依賴的package包/類
LogisimFile loadLogisimFile(File request) throws LoadFailedException {
	File actual = getSubstitution(request);
	for (File fileOpening : filesOpening) {
		if (fileOpening.equals(actual)) {
			throw new LoadFailedException(StringUtil.format(
					Strings.get("logisimCircularError"),
					toProjectName(actual)));
		}
	}

	LogisimFile ret = null;
	filesOpening.push(actual);
	try {
		ret = LogisimFile.load(actual, this);
	} catch (IOException e) {
		throw new LoadFailedException(StringUtil.format(
				Strings.get("logisimLoadError"), toProjectName(actual),
				e.toString()));
	} finally {
		filesOpening.pop();
	}
	ret.setName(toProjectName(actual));
	return ret;
}
 
開發者ID:reds-heig,項目名稱:logisim-evolution,代碼行數:25,代碼來源:Loader.java


注:本文中的com.cburch.logisim.util.StringUtil類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。