/** * Called before window creation, descendants should override to initialize the data, initialize * params. */ void preInit(XCreateWindowParams params) { state_lock = new StateLock(); initialising = InitialiseState.NOT_INITIALISED; embedded = Boolean.TRUE.equals(params.get(EMBEDDED)); visible = Boolean.TRUE.equals(params.get(VISIBLE)); Object parent = params.get(PARENT); if (parent instanceof XBaseWindow) { parentWindow = (XBaseWindow) parent; } else { Long parentWindowID = (Long) params.get(PARENT_WINDOW); if (parentWindowID != null) { parentWindow = XToolkit.windowToXWindow(parentWindowID); } } Long eventMask = (Long) params.get(EVENT_MASK); if (eventMask != null) { long mask = eventMask.longValue(); mask |= SubstructureNotifyMask; params.put(EVENT_MASK, mask); } screen = -1; }
void preInit(XCreateWindowParams params) { super.preInit(params); if (!resize_request.isInterned()) { resize_request.intern(false); } winAttr.initialFocus = true; currentInsets = new Insets(0, 0, 0, 0); // replacemenet for wdata->top, left, bottom, right applyGuessedInsets(); Rectangle bounds = (Rectangle) params.get(BOUNDS); dimensions = new WindowDimensions(bounds, getRealInsets(), false); params.put(BOUNDS, dimensions.getClientRect()); if (insLog.isLoggable(Level.FINE)) { insLog.log(Level.FINE, "Initial dimensions {0}", new Object[] {String.valueOf(dimensions)}); } // Deny default processing of these events on the shell - proxy will take care of // them instead Long eventMask = (Long) params.get(EVENT_MASK); params.add( EVENT_MASK, Long.valueOf(eventMask.longValue() & ~(FocusChangeMask | KeyPressMask | KeyReleaseMask))); }
@Test public void test_manuel_int32_t() throws IOException { // 6B 73 68 6F // 107 115 104 111 // 29547 28520 // 1869116267 byte[] input1 = {107, 115, 104, 111}; // 6B 73 68 6F Long expected1 = 1869116267L; // 1869116267 BinFileReader binFileReader = new BinFileReader(new BufferedInputStream(new ByteArrayInputStream(input1))); SignedInteger result1 = binFileReader.int32_t(); assertEquals("int32_t6B 73 68 6F asLong() = 1869116267", expected1, result1.asLong()); assertEquals( "int32_t6B 73 68 6F getSignedValue() = 1869116267", (Integer) expected1.intValue(), result1.getSignedValue()); byte[] input2 = {32, 75, -61, -68}; // 20 4B C3 BC Long expected2 = -1128051936L; // -1128051936 binFileReader = new BinFileReader(new BufferedInputStream(new ByteArrayInputStream(input2))); SignedInteger result2 = binFileReader.int32_t(); assertEquals("int32_t20 4B C3 BC asLong() = -1128051936", expected2, result2.asLong()); assertEquals( "int32_t20 4B C3 BC getSignedValue() = -1128051936", (Integer) expected2.intValue(), result2.getSignedValue()); }
private ProductData.UTC getUTCAttribute(String key, List<Attribute> globalAttributes) { Attribute attribute = findAttribute(key, globalAttributes); Boolean isModis = false; try { isModis = findAttribute("MODIS_Resolution", globalAttributes).isString(); } catch (Exception ignored) { } if (attribute != null) { String timeString = attribute.getStringValue().trim(); final DateFormat dateFormat = ProductData.UTC.createDateFormat("yyyyDDDHHmmssSSS"); final DateFormat dateFormatModis = ProductData.UTC.createDateFormat("yyyy-MM-dd HH:mm:ss.SSSSSS"); final DateFormat dateFormatOcts = ProductData.UTC.createDateFormat("yyyyMMdd HH:mm:ss.SSSSSS"); try { if (isModis) { final Date date = dateFormatModis.parse(timeString); String milliSeconds = timeString.substring(timeString.length() - 3); return ProductData.UTC.create(date, Long.parseLong(milliSeconds) * 1000); } else if (productReader.getProductType() == SeadasProductReader.ProductType.Level1A_OCTS) { final Date date = dateFormatOcts.parse(timeString); String milliSeconds = timeString.substring(timeString.length() - 3); return ProductData.UTC.create(date, Long.parseLong(milliSeconds) * 1000); } else { final Date date = dateFormat.parse(timeString); String milliSeconds = timeString.substring(timeString.length() - 3); return ProductData.UTC.create(date, Long.parseLong(milliSeconds) * 1000); } } catch (ParseException ignored) { } } return null; }
public void updateValues() { String snipeAtCfg = JConfig.queryConfiguration("snipemilliseconds", "30000"); String autoSubtractShipping = JConfig.queryConfiguration("snipe.subtract_shipping", "false"); long snipeAt = Long.parseLong(snipeAtCfg); snipeTime.setText(Long.toString(snipeAt / 1000)); autoSubtractShippingBox.setSelected(autoSubtractShipping.equals("true")); }
public static String getAsMinutes(Long value) { if (value == null) return null; Long amount = (Long) value; int sec = amount.intValue() % 60; int mins = amount.intValue() / 60; return mins + "' " + sec + "\""; }
/** * Creates the tool context denoting the range of samples that should be analysed by a tool. * * @return a tool context, never <code>null</code>. */ private ToolContext createToolContext() { int startOfDecode = -1; int endOfDecode = -1; final int dataLength = this.dataContainer.getValues().length; if (this.dataContainer.isCursorsEnabled()) { if (this.dataContainer.isCursorPositionSet(0)) { final Long cursor1 = this.dataContainer.getCursorPosition(0); startOfDecode = this.dataContainer.getSampleIndex(cursor1.longValue()) - 1; } if (this.dataContainer.isCursorPositionSet(1)) { final Long cursor2 = this.dataContainer.getCursorPosition(1); endOfDecode = this.dataContainer.getSampleIndex(cursor2.longValue()) + 1; } } else { startOfDecode = 0; endOfDecode = dataLength; } startOfDecode = Math.max(0, startOfDecode); if ((endOfDecode < 0) || (endOfDecode >= dataLength)) { endOfDecode = dataLength - 1; } return new DefaultToolContext(startOfDecode, endOfDecode); }
/** * Goes to the current cursor position of the cursor with the given index. * * @param aCursorIdx the index of the cursor to go to, >= 0 && < 10. */ public void gotoCursorPosition(final int aCursorIdx) { if ((this.mainFrame != null) && this.dataContainer.isCursorsEnabled()) { final Long cursorPosition = this.dataContainer.getCursorPosition(aCursorIdx); if (cursorPosition != null) { this.mainFrame.gotoPosition(cursorPosition.longValue()); } } }
public void apply() { long newSnipeAt = Long.parseLong(snipeTime.getText()) * 1000; // Set the default snipe for everything to be whatever was typed in. JConfig.setConfiguration("snipemilliseconds", Long.toString(newSnipeAt)); JConfig.setConfiguration( "snipe.subtract_shipping", autoSubtractShippingBox.isSelected() ? "true" : "false"); }
@Test public void test_int64_t() throws IOException { for (Long exp : expected_int64) { SignedLong result = binFileReader.int64_t(); assertEquals("int64_t " + exp + " getSignedValue()", exp, result.getSignedValue()); assertEquals("int64_t " + exp + " toString()", exp.toString(), result.toString()); } }
@Override public void doApplyInformationToEditor() { final Long stamp = myEditor.getUserData(LAST_TIME_INDENTS_BUILT); if (stamp != null && stamp.longValue() == nowStamp()) return; List<RangeHighlighter> oldHighlighters = myEditor.getUserData(INDENT_HIGHLIGHTERS_IN_EDITOR_KEY); final List<RangeHighlighter> newHighlighters = new ArrayList<RangeHighlighter>(); final MarkupModel mm = myEditor.getMarkupModel(); int curRange = 0; if (oldHighlighters != null) { int curHighlight = 0; while (curRange < myRanges.size() && curHighlight < oldHighlighters.size()) { TextRange range = myRanges.get(curRange); RangeHighlighter highlighter = oldHighlighters.get(curHighlight); int cmp = compare(range, highlighter); if (cmp < 0) { newHighlighters.add(createHighlighter(mm, range)); curRange++; } else if (cmp > 0) { highlighter.dispose(); curHighlight++; } else { newHighlighters.add(highlighter); curHighlight++; curRange++; } } for (; curHighlight < oldHighlighters.size(); curHighlight++) { RangeHighlighter highlighter = oldHighlighters.get(curHighlight); highlighter.dispose(); } } final int startRangeIndex = curRange; assert myDocument != null; DocumentUtil.executeInBulk( myDocument, myRanges.size() > 10000, new Runnable() { @Override public void run() { for (int i = startRangeIndex; i < myRanges.size(); i++) { newHighlighters.add(createHighlighter(mm, myRanges.get(i))); } } }); myEditor.putUserData(INDENT_HIGHLIGHTERS_IN_EDITOR_KEY, newHighlighters); myEditor.putUserData(LAST_TIME_INDENTS_BUILT, nowStamp()); myEditor.getIndentsModel().assumeIndents(myDescriptors); }
public void actionPerformed(ActionEvent e) { if (e.getSource() == cancel) dispose(); else try { long wohin = Long.parseLong(postf.getText(), 16); long wieweit = Long.parseLong(sizetf.getText(), 16); if (parent.hv.goTo(wohin, wieweit)) dispose(); } catch (NumberFormatException ex) { postf.setText(ex.toString()); return; } }
/** * Returns the editted value. * * @return the editted value. * @throws TagFormatException if the tag value cannot be retrieved with the expected type. */ public TagValue getTagValue() throws TagFormatException { try { long numer = Long.parseLong(m_numer.getText()); long denom = Long.parseLong(m_denom.getText()); Rational rational = new Rational(numer, denom); return new TagValue(m_value.getTag(), rational); } catch (NumberFormatException e) { e.printStackTrace(); throw new TagFormatException( m_numer.getText() + "/" + m_denom.getText() + " is not a valid rational"); } }
@Test public void test_int32_t() throws IOException { for (Long exp : expected_int32) { SignedInteger result = binFileReader.int32_t(); assertEquals("int32_t " + exp + " asInt()", exp, result.asLong()); assertEquals( "int32_t " + exp + " getSignedValue()", (Integer) exp.intValue(), result.getSignedValue()); assertEquals("int32_t " + exp + " toString()", exp.toString(), result.toString()); } }
/** Goes to the current cursor position of the last available cursor. */ public void gotoLastAvailableCursor() { if ((this.mainFrame != null) && this.dataContainer.isCursorsEnabled()) { for (int c = CapturedData.MAX_CURSORS - 1; c >= 0; c--) { if (this.dataContainer.isCursorPositionSet(c)) { final Long cursorPosition = this.dataContainer.getCursorPosition(c); if (cursorPosition != null) { this.mainFrame.gotoPosition(cursorPosition.longValue()); } break; } } } }
public void dispatchEvent(XEvent ev) { super.dispatchEvent(ev); switch (ev.get_type()) { case XConstants.CreateNotify: XCreateWindowEvent cr = ev.get_xcreatewindow(); if (xembedLog.isLoggable(PlatformLogger.FINEST)) { xembedLog.finest("Message on embedder: " + cr); } if (xembedLog.isLoggable(PlatformLogger.FINER)) { xembedLog.finer( "Create notify for parent " + Long.toHexString(cr.get_parent()) + ", window " + Long.toHexString(cr.get_window())); } embedChild(cr.get_window()); break; case XConstants.DestroyNotify: XDestroyWindowEvent dn = ev.get_xdestroywindow(); if (xembedLog.isLoggable(PlatformLogger.FINEST)) { xembedLog.finest("Message on embedder: " + dn); } if (xembedLog.isLoggable(PlatformLogger.FINER)) { xembedLog.finer("Destroy notify for parent: " + dn); } childDestroyed(); break; case XConstants.ReparentNotify: XReparentEvent rep = ev.get_xreparent(); if (xembedLog.isLoggable(PlatformLogger.FINEST)) { xembedLog.finest("Message on embedder: " + rep); } if (xembedLog.isLoggable(PlatformLogger.FINER)) { xembedLog.finer( "Reparent notify for parent " + Long.toHexString(rep.get_parent()) + ", window " + Long.toHexString(rep.get_window()) + ", event " + Long.toHexString(rep.get_event())); } if (rep.get_parent() == getWindow()) { // Reparented into us - embed it embedChild(rep.get_window()); } else { // Reparented out of us - detach it childDestroyed(); } break; } }
// Get Color as String public static String getColor(Color color) { ArrayList<String> colors = new ArrayList<String>(); colors.add(Long.toHexString(color.getRed())); colors.add(Long.toHexString(color.getGreen())); colors.add(Long.toHexString(color.getBlue())); StringBuilder buffer = new StringBuilder(); for (String c : colors) { if (c.length() == 1) { buffer.append("0"); } buffer.append(c); } return ("#" + buffer.toString()); }
public void crement(int i) { if (MesquiteWindow.getQueryMode(this)) { MesquiteWindow.respondToQueryMode("Mini scroll", command, this); return; } if (i <= maxValue && (i >= minValue) && command != null) { currentValue = i; command.doItMainThread( Long.toString(currentValue), CommandChecker.getQueryModeString("Mini scroll", command, this), this); tf.setText(Long.toString(currentValue)); decrementButton.setEnabled(i > minValue); incrementButton.setEnabled(i < maxValue); } }
/** * First argument to the program can be a number representing interval in seconds, after which * mouse will move. Recommended value is between 15 - 90. * * @param args * @throws AWTException */ public static void main(String[] args) throws AWTException { final MovableMouse mouse = new MovableMouse(); final Timer timer = new Timer(); long frequencyInSeconds = DEFAULT_FREQUENCY; try { frequencyInSeconds = (args.length > 0) ? Long.parseLong(args[0]) : DEFAULT_FREQUENCY; } catch (Exception e) { System.err.println(e); System.exit(1); } TimerTask timerTask = new TimerTask() { @Override public void run() { System.out.println("moving mouse to stay awake"); mouse.buzz(); } }; Runtime.getRuntime() .addShutdownHook( new Thread() { @Override public void run() { System.out.println("Bye bye"); } }); timer.schedule(timerTask, ONE_SECOND, frequencyInSeconds * ONE_SECOND); }
private void getPositions(HttpServletRequest request, Role item) { String[] pos = request.getParameterValues("positions"); item.clearPositions(); for (int i = 0; i < pos.length; i++) { item.addPosition(Long.parseLong(pos[i])); } }
private void getPermissions(HttpServletRequest request, Role item) { String[] per = request.getParameterValues("permissions"); item.clearPermissions(); for (int i = 0; i < per.length; i++) { item.addPermission(Long.parseLong(per[i])); } }
private boolean verifyFile(File aFile, List theFileAttribList) { Iterator it = theFileAttribList.iterator(); int theIndex = 0; String theMD5 = null; String theVal = null; long theSize; while (it.hasNext()) { try { theVal = (String) it.next(); if (theIndex == 6) { theMD5 = MD5.getMD5(aFile); if (!theVal.equals(MD5.getMD5(aFile))) { return false; } break; } if (theIndex == 5) { theSize = aFile.length(); if (theSize != Long.parseLong(theVal)) { return false; } } } catch (Exception E) { E.printStackTrace(); } theIndex++; } return true; }
@Override public int compareTo(Object o) { if (o instanceof DateAxisGraphLabel) { return Long.compare(this.date, ((DateAxisGraphLabel) o).getDate()); } return 0; }
public Chart(String filename) { try { // Get Stock Symbol this.stockSymbol = filename.substring(0, filename.indexOf('.')); // Create time series TimeSeries open = new TimeSeries("Open Price", Day.class); TimeSeries close = new TimeSeries("Close Price", Day.class); TimeSeries high = new TimeSeries("High", Day.class); TimeSeries low = new TimeSeries("Low", Day.class); TimeSeries volume = new TimeSeries("Volume", Day.class); BufferedReader br = new BufferedReader(new FileReader(filename)); String key = br.readLine(); String line = br.readLine(); while (line != null && !line.startsWith("<!--")) { StringTokenizer st = new StringTokenizer(line, ",", false); Day day = getDay(st.nextToken()); double openValue = Double.parseDouble(st.nextToken()); double highValue = Double.parseDouble(st.nextToken()); double lowValue = Double.parseDouble(st.nextToken()); double closeValue = Double.parseDouble(st.nextToken()); long volumeValue = Long.parseLong(st.nextToken()); // Add this value to our series' open.add(day, openValue); close.add(day, closeValue); high.add(day, highValue); low.add(day, lowValue); // Read the next day line = br.readLine(); } // Build the datasets dataset.addSeries(open); dataset.addSeries(close); dataset.addSeries(low); dataset.addSeries(high); datasetOpenClose.addSeries(open); datasetOpenClose.addSeries(close); datasetHighLow.addSeries(high); datasetHighLow.addSeries(low); JFreeChart summaryChart = buildChart(dataset, "Summary", true); JFreeChart openCloseChart = buildChart(datasetOpenClose, "Open/Close Data", false); JFreeChart highLowChart = buildChart(datasetHighLow, "High/Low Data", true); JFreeChart highLowDifChart = buildDifferenceChart(datasetHighLow, "High/Low Difference Chart"); // Create this panel this.setLayout(new GridLayout(2, 2)); this.add(new ChartPanel(summaryChart)); this.add(new ChartPanel(openCloseChart)); this.add(new ChartPanel(highLowChart)); this.add(new ChartPanel(highLowDifChart)); } catch (Exception e) { e.printStackTrace(); } }
public GoToDialog(HexEditor parent, long offset) { super(parent, "Go to position", true); this.parent = parent; setLayout(new GridLayout(3, 1)); Panel p; add(p = new Panel(new BorderLayout())); p.add("West", new Label("Offset:")); p.add("Center", postf = new TextField(Long.toString(offset, 16))); postf.addActionListener(this); add(p = new Panel(new BorderLayout())); p.add("West", new Label("Mark length:")); p.add("Center", sizetf = new TextField("0")); sizetf.addActionListener(this); add(p = new Panel(new FlowLayout())); p.add(ok = new Button("OK")); ok.addActionListener(this); p.add(cancel = new Button("Cancel")); cancel.addActionListener(this); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { dispose(); } }); pack(); show(); }
public void GetRecentPaperSize() { String id = Long.toString(robot_uid); paper_left = Double.parseDouble(prefs.get(id + "_paper_left", "0")); paper_right = Double.parseDouble(prefs.get(id + "_paper_right", "0")); paper_top = Double.parseDouble(prefs.get(id + "_paper_top", "0")); paper_bottom = Double.parseDouble(prefs.get(id + "_paper_bottom", "0")); }
private void checkTextfile(PlainTextResource text) { Matcher m = NUMBERPATTERN.matcher(text.getText()); while (m.find()) { long nr = Long.parseLong(text.getText().substring(m.start(), m.end())); if (nr >= 0 && nr < strUsed.length) strUsed[(int) nr] = true; } }
private void altCommitToOriginal(@NotNull DocumentEvent e) { final PsiFile origPsiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(myOrigDocument); String newText = myNewDocument.getText(); // prepare guarded blocks LinkedHashMap<String, String> replacementMap = new LinkedHashMap<String, String>(); int count = 0; for (RangeMarker o : ContainerUtil.reverse(((DocumentEx) myNewDocument).getGuardedBlocks())) { String replacement = o.getUserData(REPLACEMENT_KEY); String tempText = "REPLACE" + (count++) + Long.toHexString(StringHash.calc(replacement)); newText = newText.substring(0, o.getStartOffset()) + tempText + newText.substring(o.getEndOffset()); replacementMap.put(tempText, replacement); } // run preformat processors final int hostStartOffset = myAltFullRange.getStartOffset(); myEditor.getCaretModel().moveToOffset(hostStartOffset); for (CopyPastePreProcessor preProcessor : Extensions.getExtensions(CopyPastePreProcessor.EP_NAME)) { newText = preProcessor.preprocessOnPaste(myProject, origPsiFile, myEditor, newText, null); } myOrigDocument.replaceString(hostStartOffset, myAltFullRange.getEndOffset(), newText); // replace temp strings for guarded blocks for (String tempText : replacementMap.keySet()) { int idx = CharArrayUtil.indexOf( myOrigDocument.getCharsSequence(), tempText, hostStartOffset, myAltFullRange.getEndOffset()); myOrigDocument.replaceString(idx, idx + tempText.length(), replacementMap.get(tempText)); } // JAVA: fix occasional char literal concatenation fixDocumentQuotes(myOrigDocument, hostStartOffset - 1); fixDocumentQuotes(myOrigDocument, myAltFullRange.getEndOffset()); // reformat PsiDocumentManager.getInstance(myProject).commitDocument(myOrigDocument); Runnable task = () -> { try { CodeStyleManager.getInstance(myProject) .reformatRange(origPsiFile, hostStartOffset, myAltFullRange.getEndOffset(), true); } catch (IncorrectOperationException e1) { // LOG.error(e); } }; DocumentUtil.executeInBulk(myOrigDocument, true, task); PsiElement newInjected = InjectedLanguageManager.getInstance(myProject) .findInjectedElementAt(origPsiFile, hostStartOffset); DocumentWindow documentWindow = newInjected == null ? null : InjectedLanguageUtil.getDocumentWindow(newInjected); if (documentWindow != null) { myEditor.getCaretModel().moveToOffset(documentWindow.injectedToHost(e.getOffset())); myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); } }
public void setCurrentValueLong(long i) { if (i <= maxValue && (i >= minValue)) { currentValue = i; tf.setText(Long.toString(currentValue)); decrementButton.setEnabled(currentValue > minValue); incrementButton.setEnabled(currentValue < maxValue); } }
public void decrement() { if (MesquiteWindow.getQueryMode(this)) { MesquiteWindow.respondToQueryMode("Mini scroll", command, this); return; } if (currentValue > minValue && command != null) { currentValue--; tf.setText(Long.toString(currentValue)); command.doItMainThread( Long.toString(currentValue), CommandChecker.getQueryModeString("Mini scroll", command, this), this); enterButton.setEnabled(false); decrementButton.setEnabled(currentValue > minValue); incrementButton.setEnabled(currentValue < maxValue); } }