绘图图在Web应用程序中

我正在使用Spring开发一个Web应用程序。 我需要绘制图表并将其显示给用户。 值存储在数据库中。 我该如何实现这一目标?

Java:从Runnable返回结果

假设以下简化示例。 设B表示处理某些栅格数据的类: import java.awt.image.BufferedImage; public class B implements Runnable{ private boolean c; private Runnable f; public B (boolean c_, Runnable f_) { c = c_; f = f_;} public BufferedImage process() { //Some operations BufferedImage output = null; if (c) output = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB); return output; } public void run() { process();} } […]

使用Swing绘制选择框

我用面板和三个按钮编写了一个应用程序。 我想用鼠标添加选择这个按钮。 我的意思是我们在桌面上的Windows中。 我按下鼠标左键,随着鼠标的移动,区域选择也在增长。 是否有一个特定的接口或我是否有手动调用事件监听器的相应方法,并绘制透明矩形? 这是一张图片: 所以当我使用鼠标拖动绘制矩形时,我有一个问题,按钮正在重新绘制,因此用户可以看到闪烁按钮。 当我画矩形时,我想要这个按钮不要消失。 我认为我需要使用glassPane。 这是我的观念。 我有一个框架。 在框架中我添加了带按钮的面板,我需要另一个面板,我将绘制透明矩形。 我在想,然后我的按钮仍然不会重新粉刷。 你对这个概念有什么看法? 或者也许有人有另一个想法。 这是代码: @Override public void mousePressed(MouseEvent e) { startPoint=e.getPoint(); setOpaque(true); Graphics2D g2 = (Graphics2D)getGraphics(); Rectangle2D prostokat = new Rectangle2D.Double(); prostokat.setFrameFromDiagonal(e.getPoint().x, e.getPoint().y,startPoint.x, startPoint.y); g2.setComposite(AlphaComposite.getInstance(rule, alpha)); g2.draw(prostokat); g2.setColor(Color.BLUE); g2.fill(prostokat); } @Override public void mouseDragged(MouseEvent e) { setOpaque(true); Graphics2D g2 = (Graphics2D)getGraphics(); Rectangle2D prostokat […]

Canvas3D没有出现在Swing窗口中

我试图在Swing JPanel中插入一个Canvas3D对象,但代码似乎没有工作(即没有任何反应): Canvas3D canvas = new Canvas3D(SimpleUniverse.getPreferredConfiguration()); SimpleUniverse universe = new SimpleUniverse(canvas); BranchGroup root = new BranchGroup(); root.addChild(new ColorCube()); universe.addBranchGraph(根); universe.getViewingPlatform()setNominalViewingTransform(); canvasPanel.add(帆布); 我错过了什么? JPanel是使用NetBean的Visual Editor创建的。

使用Iterator循环时将项添加到HashMap

我有一个使用Iterator遍历HashMap的程序,并且在循环内部,我正在添加HashMap – 这导致了ConcurrentModificationException。 我已经看到ListIterator有一个add()函数来处理这个,但Iterator没有。 HashMap设置如下 – HashMap<Pair, Object> 像这样的迭代器 – Iterator<Entry<Pair, Object>> iter; 使用Object(不是真名)是我程序中的一个类。 在我循环或任何其他选项时,有谁知道如何添加到迭代器?

如何在Android中的PopupWindow中创建Spinner小部件? 单击Spinner时获取BadTokenException

我一直在网上搜索这个问题的解决方案,但不幸的是,我似乎无法找到答案。 我为PopupWindow创建了一个XML文件,里面有一个Spinner。 在按钮事件监听器中,我调用以下代码来膨胀PopupWindow并在屏幕上显示它。 LayoutInflater inflater = getLayoutInflater(); settings_layout = inflater.inflate(R.layout.setting_popout, (ViewGroup) findViewById(R.id.setting_popout)); // Creates a popup window of required width and height, and displays // the popup in the center of the screen. pw_settings = new PopupWindow(settings_layout, 400, 470, true); pw_settings.showAtLocation(settings_layout, Gravity.CENTER, 0, 0); spColors = (Spinner) settings_layout.findViewById(R.id.linecolor); // Sets the initial values of the […]

Android:TimeStamp转换问题!

我正在解析一些xml的电视指南数据并遇到这个18位数的时间戳(633934980000869533)。 看起来像C#的DateTime滴答声。 有谁知道如何将其转换为常规的Java日期/时间?

为什么Java lamdareflection性能会变差

我构建了一个简单的测试,用Java LambdaMetafactory测量类reflection的性能。 根据各种post,使用LambdaMetafactory的reflection与直接调用getter一样快。 这似乎是最初的,但过了一段时间性能下降。 其中一个测试节目(这似乎是大势所趋): 原来: GET – REFLECTION: Runtime=2.841seconds GET – DIRECT: Runtime=0.358seconds GET – LAMBDA: Runtime=0.362seconds SET – REFLECTION: Runtime=3.86seconds SET – DIRECT: Runtime=0.507seconds SET – LAMBDA: Runtime=0.455seconds 最后: GET – REFLECTION: Runtime=2.904seconds GET – DIRECT: Runtime=0.501seconds GET – LAMBDA: Runtime=5.299seconds SET – REFLECTION: Runtime=4.62seconds SET – DIRECT: Runtime=1.723seconds SET – LAMBDA: Runtime=5.149seconds […]

Vaadin的原生地点选择

我正在使用Vaadin 。 我想使用Native Select在区域设置之间切换。 @Override public void valueChange(ValueChangeEvent event) { UI.getCurrent().setLocale(loc); } 我想使用event.getProperty()但“loc”必须是Locale类型。 如何获得原生选择的值并将其转换为Locale类型?

断言网页中缺少元素,给出NoSuchElementException

需要声明网页中没有这样的元素,当尝试使用fieldValueBox.isDisplayed(); 而不是“假”它抛出“NoSuchElementFound”exception。 现在我正在使用’try catch’并在’catch’中做出决定