为JSXGraph设置网格参数的正确方法是什么? According to here,
... [默认]值必须在JSXGraph板初始化之前被覆盖。
JXG.Options.grid.strokeColor = "pink";
JXG.Options.grid.strokeWidth = 14.0;
board = JXG.JSXGraph.initBoard('box', {boundingbox: [-5,5,5,-5], axis: true});
并不影响任何事情。
但是,我可以在现有主板上创建一个网格,但由于某种原因,它会在现有网格下面绘制。如果用grid: false
初始化,董事会似乎也会忽略,所以我似乎无法解决它。有什么想法吗?
我找到了
JXG.JSXGraph.initBoard('box', {boundingbox: [-5,5,5,-5], axis: true, grid: true})
在axis: true
参数绘制的网格顶部绘制一个额外的网格。但是,axis:true
参数绘制的第一个网格的颜色会耦合到
JXG.Options.axis.ticks.strokeColor
参数。由于某些原因,此参数会更改刻度颜色和轴绘制的网格(即使在axis: true
和grid: false
的情况下也会绘制)。 Here is an example of what I mean
答案 0 :(得分:0)
在JSXGraph中有两种类型的网格线:
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
public class AppletToServletExample extends Applet {
private TextField inputField = new TextField(10);
private TextField resultField = new TextField(10);
public void init() {
// add input label, field and send button
add(new Label("Input Your Name", Label.RIGHT));
add(inputField);
Button sendButton = new Button("Send");
add(sendButton);
sendButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
SendData();
}
});
// add output label as a non editable field
add(new Label("Output:", Label.RIGHT));
add(resultField);
resultField.setEditable(false);
}
// Get a connection to the servlet.
private URLConnection getServletConnection() throws MalformedURLException,
IOException {
URL urlServlet = new URL(getCodeBase(), "applettoservlet");
URLConnection con = urlServlet.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setRequestProperty("Content-Type",
"application/x-java-serialized-object");
return con;
}
// Send the inputField data to the servlet and show the result in the
// outputField.
private void SendData() {
try {
String input = inputField.getText();
// send data to the servlet
URLConnection con = getServletConnection();
OutputStream outputStream = con.getOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(outputStream);
oos.writeObject(input);
oos.flush();
oos.close();
// receive result from servlet
InputStream inputStream = con.getInputStream();
ObjectInputStream inputFromServlet = new ObjectInputStream(
inputStream);
String result = (String) inputFromServlet.readObject();
inputFromServlet.close();
inputStream.close();
// show result
resultField.setText(result);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
显示的网格对象,其属性可以使用grid:true
进行设置。两个网格线之间的距离设置为JXG.Options.grid
和JXG.Options.grid.gridX
。JXG.Options.grid.gridY
如果这些属性具有负值,则刻度将无限延伸,因此将显示为网格线。
JXG.Options.axis.ticks.majorHeight = 20;
JXG.Options.axis.ticks.minorHeight = 10;
的默认值为JXG.Options.axis.ticks.majorHeight
。小蜱和主要蜱将具有相同的颜色。(true)网格的线条在用户坐标中始终具有相同的距离,与缩放级别无关,而无限刻度线将适应缩放级别。 如果用户选择高缩放级别,则浏览器可能因许多网格线而冻结。