本文整理汇总了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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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));
}
示例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);
}
}
示例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;
}
示例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"));
}
}
示例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());
}
}
}
示例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;
}
示例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;
}
示例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;
}