public void actionPerformed(ActionEvent event) { JMenuItem source = (JMenuItem) (event.getSource()); for (GraphView v : gp.getGraphViewList()) { if (v.getMenuText().equals(source.getText())) { v.view(); repaint(); return; } } for (GraphDrawer d : gp.getGraphDrawerList()) { if (d.getMenuText().equals(source.getText())) { d.layout(); repaint(); return; } } for (GraphUtility u : gp.getGraphUtilityList()) { if (u.getMenuText().equals(source.getText())) { u.apply(); repaint(); return; } } for (GraphExperiment ge : gp.getGraphExperimentList()) { if (ge.getMenuText().equals(source.getText())) { ge.experiment(); repaint(); return; } } }
public void updateTrace(int dx) { for (int i = 0; i < getNumFns(); i += 1) { traceLoc += dx; if (traceLoc > graph.getXMax()) traceLoc = (int) graph.getXMax(); else if (traceLoc < graph.getXMin()) traceLoc = (int) graph.getXMin(); } }
// Called once the background activity has completed @Override protected void onPostExecute(Integer result) { // Init TextView Widget to display ADC sensor value in numeric. GraphView mGraphView = (GraphView) findViewById(R.id.graph); mGraphView.addDataPoint(result); TextView mTextView = (TextView) findViewById(R.id.value); mTextView.setText(String.valueOf(result)); }
public void calcZeros(ArrayAdapter<String> zerosArr, int nFns) { int n; String title; for (int i = 0; i < nFns; i += 1) { if (!graphCalcs[i].empty()) { title = "Fn" + Integer.toString(i + 1) + "(x):"; n = graphCalcs[i].calcZeros( zeros[i], graph.getXLeft(), graph.getXRight(), graph.getYBot(), graph.getYTop(), graph.getXMin(), graph.getXMax(), graph.getYMin(), graph.getYMax(), graph.getXUnitLen()); // Log.v ("calcZeros",Integer.toString(n)); if (n == 0) title += " None"; zerosArr.add(title); // Convert x values of zeros to strings for (int k = 0; k < n; k += 1) { float num = zeros[i][k]; if ((num > -0.001 && num < 0) || (num < 0.001 && num > 0)) num = 0; String numStr = ComplexNumber.roundStr(num, 3); zerosArr.add(" x = " + numStr); } } } }
public void plotFns(float[][] fnPts, int nFns) { for (int i = 0; i < nFns; i += 1) { if (!graphCalcs[i].empty()) { /* Log.v ("plotFns",Float.toString(graph.getXMax())+" "+ Float.toString(graph.getYMax())+" "+Float.toString(graph.getXLeft ())+ " "+Float.toString(graph.getXRight ())+" "+ Float.toString(graph.getYBot ())+" "+Float.toString(graph.getYTop ())); */ graphCalcs[i].graphFn( fnPts[i], graph.getXLeft(), graph.getXRight(), graph.getYBot(), graph.getYTop(), graph.getXMin(), graph.getXMax(), graph.getYMin(), graph.getYMax(), graph.getXUnitLen()); /* for (int j=0;j<N_FN_PTS*4;j+=4) { Log.v ("plotFns", Float.toString(fnPts[i][j])+","+Float.toString(fnPts[i][j+1])+ " "+ Float.toString(fnPts[i][j+2])+","+Float.toString(fnPts[i][j+3])); } */ } else { clearArr(fnPts[i]); } } }
public static Graph addGraph(final GraphView graphView, final int color, final long maxNsecs) { final Graph graph = new Graph( color, maxNsecs, graphView.getGraphWidth(), graphView.getGraphHeight(), graphView.getGraphStrokeWidth()); graphView.addGraph(graph); return graph; }
private ListMultimap<String, TextHit> query( Node property, String queryString, int limit, ExecutionContext execCxt) { // use the graph information in the text index if possible if (textIndex.getDocDef().getGraphField() != null && execCxt.getActiveGraph() instanceof GraphView) { GraphView activeGraph = (GraphView) execCxt.getActiveGraph(); if (!Quad.isUnionGraph(activeGraph.getGraphName())) { String uri = activeGraph.getGraphName() != null ? TextQueryFuncs.graphNodeToString(activeGraph.getGraphName()) : Quad.defaultGraphNodeGenerated.getURI(); String escaped = QueryParserBase.escape(uri); String qs2 = textIndex.getDocDef().getGraphField() + ":" + escaped; queryString = "(" + queryString + ") AND " + qs2; } } // for language-based search extension if (textIndex.getDocDef().getLangField() != null) { String field = textIndex.getDocDef().getLangField(); if (langArg != null) { String qs2 = !"none".equals(langArg) ? field + ":" + langArg : "-" + field + ":*"; queryString = "(" + queryString + ") AND " + qs2; } } Explain.explain(execCxt.getContext(), "Text query: " + queryString); if (log.isDebugEnabled()) log.debug("Text query: {} ({})", queryString, limit); String cacheKey = limit + " " + property + " " + queryString; Cache<String, ListMultimap<String, TextHit>> queryCache = (Cache<String, ListMultimap<String, TextHit>>) execCxt.getContext().get(cacheSymbol); if (queryCache == null) { /* doesn't yet exist, need to create it */ queryCache = CacheFactory.createCache(CACHE_SIZE); execCxt.getContext().put(cacheSymbol, queryCache); } final String queryStr = queryString; // final needed for the lambda function ListMultimap<String, TextHit> results = queryCache.getOrFill( cacheKey, () -> { List<TextHit> resultList = textIndex.query(property, queryStr, limit); ListMultimap<String, TextHit> resultMultimap = LinkedListMultimap.create(); for (TextHit result : resultList) { resultMultimap.put(result.getNode().getURI(), result); } return resultMultimap; }); return results; }
public void mouseClicked(MouseEvent e) { if (!(e.getSource().getClass().getName()).equalsIgnoreCase("VisualItem") && !UILib.isButtonPressed(e, button1)) { if (gv.getDisplay().getCursor().getType() == (Cursor.DEFAULT_CURSOR)) { // release all focus and neighbour highlight TupleSet ts = vis.getGroup(Visualization.FOCUS_ITEMS); if (gv.getRecStatus() == 2 && gv.fromIndirect && (ts.getTupleCount() == 0) && !gv.fromAll) gv.showDirectGraph(); ts.clear(); vis.removeGroup("depthEdge"); gv.releaseSearchFocus(); } } if (UILib.isButtonPressed(e, button1) && e.getClickCount() == 1) { if (gv.getDisplay().getCursor().getName().equals("zoom")) admin.toggleZoom(); else if (gv.getDisplay().getCursor().getName().equals("zoomout")) admin.toggleZoomOut(); else if (gv.getDisplay().getCursor().getName().equals("zoomin")) admin.toggleZoomIn(); else if (gv.getDisplay().getCursor().getName().equals("zoomout1")) admin.toggleZoomOut1(); else if (gv.getDisplay().getCursor().getName().equals("zoomin1")) admin.toggleZoomIn1(); else if (gv.getDisplay().getCursor().getName().equals("pan")) admin.togglePan(); } }
private void showPage(int page, float zoom) throws Exception { long startTime = System.currentTimeMillis(); long middleTime = startTime; try { // free memory from previous page mGraphView.setPageBitmap(null); mGraphView.updateImage(); mPdfPage = mPdfFile.getPage(page, true); int num = mPdfPage.getPageNumber(); int maxNum = mPdfFile.getNumPages(); float wi = mPdfPage.getWidth(); float hei = mPdfPage.getHeight(); String pageInfo = new File(pdffilename).getName() + " - " + num + "/" + maxNum + ": " + wi + "x" + hei; mGraphView.showText(pageInfo); Log.i(TAG, pageInfo); RectF clip = null; middleTime = System.currentTimeMillis(); Bitmap bi = mPdfPage.getImage((int) (wi * zoom), (int) (hei * zoom), clip, true, true); mGraphView.setPageBitmap(bi); mGraphView.updateImage(); } catch (Throwable e) { Log.e(TAG, e.getMessage(), e); mGraphView.showText("Exception: " + e.getMessage()); } long stopTime = System.currentTimeMillis(); mGraphView.pageParseMillis = middleTime - startTime; mGraphView.pageRenderMillis = stopTime - middleTime; }
private void updateImageStatus() { // Log.i(TAG, "updateImageStatus: " + (System.currentTimeMillis()&0xffff)); if (backgroundThread == null) { mGraphView.updateUi(); return; } mGraphView.updateUi(); mGraphView.postDelayed( new Runnable() { @Override public void run() { updateImageStatus(); } }, 1000); }
private synchronized void startRenderThread(final int page, final float zoom) { if (backgroundThread != null) return; mGraphView.showText("reading page " + page + ", zoom:" + zoom); backgroundThread = new Thread( new Runnable() { @Override public void run() { try { if (mPdfFile != null) { // File f = new File("/sdcard/andpdf.trace"); // f.delete(); // Log.e(TAG, "DEBUG.START"); // Debug.startMethodTracing("andpdf"); showPage(page, zoom); // Debug.stopMethodTracing(); // Log.e(TAG, "DEBUG.STOP"); } } catch (Exception e) { Log.e(TAG, e.getMessage(), e); } backgroundThread = null; } }); updateImageStatus(); backgroundThread.start(); }
public void actionPerformed(ActionEvent e) { if (e.getSource() == jbColor) { ColorChooseDialog ccd = new ColorChooseDialog(this); edge.color = ccd.getColor(); colorLabel.setBackground(edge.color); return; } if (e.getSource() == jcbAnchored) { edge.setFixed(jcbAnchored.isSelected()); return; } Double w = 0d; if (e.getSource() != jbDelete) { try { w = Double.parseDouble(tf.getText()); } catch (NumberFormatException ve) { w = Double.NaN; } // An empty String is considered as 0. if (tf.getText().length() == 0) w = 0d; } if (w == 0) { control .getDataFramePanel() .setValueAt( new EdgeWeight(0), netzListe.getNodes().indexOf(edge.from), netzListe.getNodes().indexOf(edge.to), edge.layer); netzListe.removeEdge(edge); } else { edge.setW(tf.getText()); int n = Integer.parseInt(spinner.getModel().getValue().toString()); edge.linewidth = n; control .getDataFramePanel() .setValueAt( new EdgeWeight(tf.getText()), netzListe.getNodes().indexOf(edge.from), netzListe.getNodes().indexOf(edge.to), edge.layer); } netzListe.repaint(); dispose(); }
private void showPage(int page, float zoom) throws Exception { // long startTime = System.currentTimeMillis(); // long middleTime = startTime; try { // free memory from previous page mGraphView.setPageBitmap(null); mGraphView.updateImage(); // Only load the page if it's a different page (i.e. not just changing the zoom level) if (mPdfPage == null || mPdfPage.getPageNumber() != page) { mPdfPage = mPdfFile.getPage(page, true); } // int num = mPdfPage.getPageNumber(); // int maxNum = mPdfFile.getNumPages(); float width = mPdfPage.getWidth(); float height = mPdfPage.getHeight(); // String pageInfo= new File(pdffilename).getName() + " - " + num +"/"+maxNum+ ": " + width + // "x" + height; // mGraphView.showText(pageInfo); // Log.i(TAG, pageInfo); RectF clip = null; // middleTime = System.currentTimeMillis(); Bitmap bi = mPdfPage.getImage((int) (width * zoom), (int) (height * zoom), clip, true, true); mGraphView.setPageBitmap(bi); mGraphView.updateImage(); writeTempFileToDisc(bi); // bi.recycle();//ADDED FOR EFFICIENCY File dir = Environment.getExternalStorageDirectory(); File file = new File(dir, IMAGE_PATH + mPage + ".jpg"); mImageUri = Uri.fromFile(file); System.out.println("Displaying " + mImageUri.getPath()); mAllShareService.start(mImageUri.getPath()); if (progress != null) progress.dismiss(); } catch (Throwable e) { Log.e(TAG, e.getMessage(), e); mGraphView.showText("Exception: " + e.getMessage()); } // long stopTime = System.currentTimeMillis(); // mGraphView.pageParseMillis = middleTime-startTime; // mGraphView.pageRenderMillis = stopTime-middleTime; }
private void parsePDF(String filename, String password) throws PDFAuthenticationFailureException { long startTime = System.currentTimeMillis(); try { File f = new File(filename); long len = f.length(); if (len == 0) { mGraphView.showText("file '" + filename + "' not found"); } else { mGraphView.showText("file '" + filename + "' has " + len + " bytes"); openFile(f, password); } } catch (PDFAuthenticationFailureException e) { throw e; } catch (Throwable e) { e.printStackTrace(); mGraphView.showText("Exception: " + e.getMessage()); } long stopTime = System.currentTimeMillis(); mGraphView.fileMillis = stopTime - startTime; }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // get handles to Views defined in our layout file mGraph = (GraphView) findViewById(R.id.graph); mValueTV = (TextView) findViewById(R.id.value); mGraph.setMaxValue(1024); }
private void updateImageStatus() { // Log.i(TAG, "updateImageStatus: " + (System.currentTimeMillis()&0xffff)); if (backgroundThread == null) { mGraphView.updateUi(); /*if (progress != null) progress.dismiss();*/ return; } mGraphView.updateUi(); mGraphView.postDelayed( new Runnable() { public void run() { updateImageStatus(); /*if (progress != null) progress.dismiss();*/ } }, 1000); }
/** * Open a specific pdf file. Creates a DocumentInfo from the file, and opens that. * * <p><b>Note:</b> Mapping the file locks the file until the PDFFile is closed. * * @param file the file to open * @throws IOException */ public void openFile(File file, String password) throws IOException { // first open the file for random access RandomAccessFile raf = new RandomAccessFile(file, "r"); // extract a file channel FileChannel channel = raf.getChannel(); // now memory-map a byte-buffer ByteBuffer bb = ByteBuffer.NEW(channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size())); // create a PDFFile from the data if (password == null) mPdfFile = new PDFFile(bb); else mPdfFile = new PDFFile(bb, new PDFPassword(password)); mGraphView.showText("Anzahl Seiten:" + mPdfFile.getNumPages()); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_skbangraph2); // 画面サイズの取得 WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); // 画面サイズの4分の1をViewのサイズとして設定する int width = (int) (display.getWidth()); // int height = (int)(GraphView.getGraphHeight()); int height = (int) (GraphView.getGraphHeight()); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(width, height); findViewById(R.id.view1).setLayoutParams(params); }
public void update() { // Log.v("WeightWatcher.ProcessWatcher", // "MSG_UPDATE pss=" + mMemInfo.currentPss); mText.setText( "(" + mPid + (mPid == android.os.Process.myPid() ? "/A" // app : "/S") // service + ") up " + getUptimeString() + " P=" + mMemInfo.currentPss + " U=" + mMemInfo.currentUss); mRamGraph.invalidate(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mGraph = (GraphView) findViewById(R.id.graph); mGraph.setMaxValue(1024); // Create TCP server (based on MicroBridge LightWeight Server) try { mServer = new Server(4568); // Same port number used in ADK firmware mServer.start(); } catch (IOException e) { Log.e(TAG, "Unable to start TCP server", e); System.exit(-1); } mServer.addListener( new AbstractServerListener() { @Override public void onReceive(org.microbridge.server.Client client, byte[] data) { if (data.length < 2) return; mSensorValue = (data[0] & 0xff) | ((data[1] & 0xff) << 8); // Any update to UI can not be carried out in a non UI thread // like the one used for Server. Hence runOnUIThread is used. runOnUiThread( new Runnable() { @Override public void run() { new UpdateData().execute(mSensorValue); } }); } }); }
public Image getScaledGraphImage(double width, double height) { return graph.getScaledImage(width, height); }
public int getLegendYPosition() { return graph.getLegendYPosition(); }
public int getYGraphPt(float val) { return (int) graph.getYMax() - graphCalcs[0].realToGraph( val, graph.getYBot(), graph.getYTop(), graph.getYMin(), graph.getYMax()); }
public void repaintGraph() { graph.populateGraphElements(); graph.paintComponent(graph.getGraphics()); }
public void initTrace() { for (int i = 0; i < getNumFns(); i += 1) { traceLoc = (int) ((graph.getXMin() + graph.getXMax()) / 2); } }
public MainView(MainModel m) { model = m; /** ********* Begin: Initialize components **************** */ // create menu bar menuBar = new JMenuBar(); // create file menu fileMenu = new JMenu("File"); loadConfigItem = new JMenuItem("Load Parameters..."); loadConfigItem.setAccelerator(KeyStroke.getKeyStroke("ctrl L")); saveConfigItem = new JMenuItem("Save Parameters..."); saveConfigItem.setAccelerator(KeyStroke.getKeyStroke("ctrl S")); saveGraphItem = new JMenuItem("Save Graph..."); saveGraphItem.setAccelerator(KeyStroke.getKeyStroke("ctrl G")); preferencesItem = new JMenuItem("Preferences..."); preferencesItem.setAccelerator(KeyStroke.getKeyStroke("ctrl P")); exitItem = new JMenuItem("Exit"); exitItem.setAccelerator(KeyStroke.getKeyStroke("ctrl Q")); fileMenu.add(loadConfigItem); fileMenu.add(saveConfigItem); fileMenu.addSeparator(); fileMenu.add(saveGraphItem); fileMenu.addSeparator(); fileMenu.add(preferencesItem); fileMenu.addSeparator(); fileMenu.add(exitItem); // // create table menu Database db = model.populateTableList(); if (db == null) { // TODO: do something } else { model.setDb(db); // TODO: do other stuff here } // create tools menu toolsMenu = new JMenu("Tools"); runItem = new JMenuItem("Run Query"); runItem.setAccelerator(KeyStroke.getKeyStroke("ctrl R")); advancedItem = new JMenuItem("Advanced Query"); // TODO: add accelerator forceItem = new JMenuItem("Force Requery"); forceItem.setAccelerator(KeyStroke.getKeyStroke("ctrl Y")); diffItem = new JMenuItem("Run Diff..."); diffItem.setAccelerator(KeyStroke.getKeyStroke("ctrl I")); exportDataItem = new JMenuItem("Export Data..."); exportDataItem.setAccelerator(KeyStroke.getKeyStroke("ctrl E")); displayDbs = new JMenuItem("Display Tables..."); displayReplacementFields = new JMenuItem("Display Replacement Fields..."); displayDefaultLabels = new JMenuItem("Display Default Labels..."); toolsMenu.add(runItem); toolsMenu.add(advancedItem); toolsMenu.add(forceItem); toolsMenu.add(diffItem); // toolsMenu.add(preferencesItem); toolsMenu.add(exportDataItem); toolsMenu.addSeparator(); toolsMenu.add(displayDbs); toolsMenu.add(displayReplacementFields); toolsMenu.add(displayDefaultLabels); // create help menu helpMenu = new JMenu("Help"); describeTableItem = new JMenuItem("Describe Table"); describeTableItem.setAccelerator(KeyStroke.getKeyStroke("ctrl T")); helpItem = new JMenuItem("Help Contents"); helpItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { new HelpView(); } }); helpMenu.add(describeTableItem); helpMenu.add(helpItem); // add menus to menu bar menuBar.add(fileMenu); menuBar.add(toolsMenu); menuBar.add(helpMenu); // create main content panel allContent = new JPanel(); // fetch info to populate parameter fields Vector<String> colNum = model.getTableColumnNamesNum(); Vector<String> colAll = model.getTableColumnNamesAll(); // setup history panel history = new HistoryView(); // setup parameter panel params = new ParameterView(this, colNum, colAll); Dimension dim = params.getSavedWindowSize(); if (dim != null) { preferred_height = (int) dim.getHeight(); preferred_width = (int) dim.getWidth(); } preferencesItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { new AdvancedOptions(params); } }); // setup graph panel graph = new GraphView(this, params); JSplitPane splitPaneRight = new JSplitPane(JSplitPane.VERTICAL_SPLIT, graph, history); splitPaneRight.setOneTouchExpandable(true); splitPaneRight.setDividerLocation((int) (preferred_height * 0.7)); graph.setMinimumSize( new Dimension((int) (0.5 * preferred_width), (int) (0.5 * preferred_height))); JSplitPane splitPaneLeft = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, params, splitPaneRight); splitPaneLeft.setOneTouchExpandable(true); splitPaneLeft.setDividerLocation(333); params.setMinimumSize(new Dimension((int) (.2 * preferred_width), (preferred_height))); /** ********* End: Initialize components **************** */ /** ********* Start: Layout components **************** */ allContent.setPreferredSize(new Dimension(preferred_width, preferred_height)); // initialize layout GridBagLayout gridbag = new GridBagLayout(); allContent.setLayout(gridbag); GridBagConstraints c = new GridBagConstraints(); // layout parameter panel c.fill = GridBagConstraints.BOTH; c.weightx = 1; c.weighty = 1; allContent.add(splitPaneLeft, c); // set menu bar and add panel to the content pane setJMenuBar(menuBar); setContentPane(allContent); /** ********* End: Layout components **************** */ setTitle(version); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); pack(); if (db == null) { appendToHistory("Please specify a database to use (Tools > Display Tables)\n"); } gridbag = null; c = null; splitPaneRight = null; splitPaneLeft = null; colNum = null; }
public void setPointType(int index) { graph.setPointType(index); }
public void setLegendYPosition(int parseInt) { if (graph == null) { return; } graph.setLegendYBase(parseInt); }
public void setLegendPosition(int selectedIndex) { graph.setLegendPosition(selectedIndex); }
public void setErrorBars(int index) { graph.setErrorBars(index); }