I have installed NetBeans 8.1 and am trying it for my first time (on Windows 7 Home Premium, sp 1), and much of the Javadoc comes up with "Javadoc not found".
I have one platform set up, which has this for source:
C:\Program Files\Java\jdk1.8.0_92\src.zip
C:\Program Files\Java\jdk1.8.0_92\javafx-src.zip
And this for Javadoc:
https://docs.oracle.com/javase/8/docs/api/
http://docs.oracle.com/javase/8/javafx/api/
And for many things, Javadoc come up missing.
Using the Layout sample project from Oracle...
http://docs.oracle.com/javafx/2/layout/builtin_layouts.htm
I am looking at LayoutSample.java, here...
private void addStackPane(HBox hb) {
StackPane stack = new StackPane();
Rectangle helpIcon = new Rectangle(30.0, 25.0);
helpIcon.setFill(new LinearGradient(0,0,0,1, true, CycleMethod.NO_CYCLE,
new Stop[]{
new Stop(0,Color.web("#4977A3")),
new Stop(0.5, Color.web("#B0C6DA")),
new Stop(1,Color.web("#9CB6CF")),}));
helpIcon.setStroke(Color.web("#D0E6FA"));
helpIcon.setArcHeight(3.5);
helpIcon.setArcWidth(3.5);
Text helpText = new Text("?");
helpText.setFont(Font.font("Verdana", FontWeight.BOLD, 18));
helpText.setFill(Color.WHITE);
helpText.setStroke(Color.web("#7080A0"));
stack.getChildren().addAll(helpIcon, helpText);
stack.setAlignment(Pos.CENTER_RIGHT);
// Add offset to right for question mark to compensate for RIGHT
// alignment of all nodes
StackPane.setMargin(helpText, new Insets(0, 10, 0, 0));
hb.getChildren().add(stack);
HBox.setHgrow(stack, Priority.ALWAYS);
}
And I can get class Javadoc for Rectangle and StackPane, and moving along, I cannot get Javadoc for setFill(), or setFont() (in the code sample). getChildren() worked!
Am I missing something? TIA, Mark
Related
I am trying to run an AnyLogic model developed a few years ago and I do not have access to the person who coded it. I have very limited knowledge of Java. The model is built based on data being read in from an XML file. The first step is to read the layout data from an XML file and draw the layout. It used to work fine but with AnyLogic version changes, it stopped working. I get the following error:
" (RectangularNode) : The creation of space markup element isn't finished. Please use initialize() function."
The code that gets highlighted as the source of the error is:
((Agent)temp).setLocation(shapeLayoutObj);
What is interesting is that couple RectangularNodes do get drawn before this error occurs. The surrounding code is given below. The above statement identified in the console window as the error source is close to the bottom of the code provided below.
/* Layout drawing */
//Initializing objects
int scale=30;
Layout layout= CMSDDocument.getDataSection().getLayout();
List<LayoutObject> layoutObj =CMSDDocument.getDataSection().getLayoutObject();
double xLoc, yLoc, width, depth;
double xOffset = 50.0;
double yOffset = 100.0;
String layoutName;
width = layout.getBoundary().getWidth().doubleValue()*scale;
depth = layout.getBoundary().getDepth().doubleValue()*scale;
RectangularNode shapeCellArea = new RectangularNode(this, SHAPE_DRAW_2D3D, true, xOffset, yOffset, 0.0, width, depth, 0, null, Color.red, 2.0, LINE_STYLE_SOLID, POSITION_CHOICE_RANDOM, new Attractor(0,0,0));
ShapeText text = new ShapeText(SHAPE_DRAW_2D3D,true,xOffset+width/2,yOffset-20,0.0,0.0,red,"SHOP FLOOR",new Font ("Calibri", Font.BOLD , 15),TextAlignment.ALIGNMENT_CENTER);
presentation.add(shapeCellArea);
presentation.add(text);
LinkedHashMap<String,RectangularNode> floorLayout=new LinkedHashMap<String,RectangularNode>();
boolean found;
int j;
//For every layout description
for(int i= 0; i<layout.getPlacement().size();i++){
//Getting the name and the description
layoutName = layout.getPlacement().get(i).getLayoutElementIdentifier();
xLoc = layout.getPlacement().get(i).getLocation().getX().doubleValue()*scale + xOffset;
yLoc = layout.getPlacement().get(i).getLocation().getY().doubleValue()*scale + yOffset;
found = false;
j = 0;
//Looking for the layout object with tthe same name as the layout description
while (!found && j<layoutObj.size()){
if (layoutName.equals(layoutObj.get(j).getIdentifier())) {
//Getting layou values
width = layoutObj.get(j).getBoundary().getWidth().doubleValue()*scale;
depth = layoutObj.get(j).getBoundary().getDepth().doubleValue()*scale;
RectangularNode shapeLayoutObj=null;
//Configure the shape
if(layoutName.contains("Mc")){
shapeLayoutObj = new RectangularNode(this, SHAPE_DRAW_2D3D, true, xLoc, yLoc, 0.0, width, depth, 0, null, Color.black, 2.0, LINE_STYLE_DASHED, POSITION_CHOICE_BY_ATTRACTORS,new Attractor(width/2,depth/2,0));
}
else{
shapeLayoutObj = new RectangularNode(this, SHAPE_DRAW_2D3D, true, xLoc, yLoc, 0.0, width, depth, 0, null, Color.black, 2.0, LINE_STYLE_DASHED, POSITION_CHOICE_RANDOM);
}
text = new ShapeText(SHAPE_DRAW_2D3D,true,xLoc+width/2,yLoc-15,0.0,0.0,black,layoutName,new Font ("Calibri", Font.PLAIN , 11),TextAlignment.ALIGNMENT_CENTER);
presentation.add(shapeLayoutObj);
presentation.add(text);
//Associate the shape with a machine or a delay
Iterator<ArrayList<Machine>> cell=machineList.iterator();
boolean foundAgent=false;
while(cell.hasNext()&&!foundAgent){
Iterator<Machine> machines=cell.next().iterator();
while(machines.hasNext()&&!foundAgent){
Machine temp=((Machine)machines.next());
if(temp.name.equals(layoutName)){
foundAgent=true;
((Agent)temp).setLocation(shapeLayoutObj);
ShapeButton button = new ShapeButton(Main.this, true, xLoc,yLoc+depth+5,40, 20.0,controlDefault, controlDefault,
true,new Font("Dialog", 0, 11 ),"Go to" ) {
public void action(){
getExperimentHost().setPresentable(temp);
}
};
presentation.add(button);
}
}
}
I understand from past exchanges that AnyLogic switched from Java Swing (in AnyLogic7 when the model was developed) to a Web-based UI and wonder if this error is due to that switch. In AnyLogic help file, RectangularNode function is identified as "deprecated in version 8.4, will be removed in the next release". I am now using AnyLogic 8 Personal Learning Edition 8.5.2 and hence I figure that this function has been removed. Wish the error message said that! Wish also that the help file suggested the new function corresponding to the deprecated function. It is also confusing that "Rectangular Node" continues to show up in the current version as a space markup element on the process modeling library palette. Guess the underlying code has changed for that element.
I looked at AnyLogic help and best I could figure that "ShapeRectangle" may be the new function that I should use to replace "RectangularNode" function but the "ShapeRectangle" function doesn't allow defining attractors. And the "ShapeRectangle" function appears to correspond to Rectangle element in the Presentation Palette rather than to the Rectangular Node in Process Modeling Library.
Kindly point me in the right direction. Should I be replacing all instances of RectangularNode or is the error something else? If I should be replacing the RectangularNode function, what function should I be using instead?
A helpful colleague pointed out that:
"
It looks like only the RectangularNode constructors with ShapeDraw parameters are deprecated. The basic one is not.
RectangularNode's parent class AreaNode has a method to add attractors.
This would lead me to think:
a) you should not replace RectangularNode. ShapeRectangle is about shape but you can't just use a shape as a node.
b) AreaNode, the superclass of RectangularNode , has methods to add attractors so you can use those."
Based on the advice and some trial and error, I used the following statements to replace the deprecated version of RectangularNode. The compiler no longer shows the message about the RectangularNode being deprecated.
// Replacement for above statement added below by SJ on 7/3/20
RectangularNode shapeCellArea = new RectangularNode(this);
shapeCellArea.setPos(xOffset, yOffset, 0.0);
shapeCellArea.setLineColor(Color.red);
shapeCellArea.setLineStyle(LINE_STYLE_SOLID);
shapeCellArea.setLineWidth(2.0);
shapeCellArea.setPositionChoiceMode(POSITION_CHOICE_RANDOM);
shapeCellArea.setSize(width,depth);
shapeCellArea.addAttractor(new Attractor(0,0,0));
// ShapeDrawMode SHAPE_DRAW_2D3D is default mode so don't have to set that.
// end of code added by SJ on 7/3/20
Unfortunately the above changes did not remove the error. Still trying to figure out the error message and will post it as a new question.
---------- The above progress update was posted on July 4, 2020. Additional information below added on July 17, 2020 ------------
With some onlines searches and guided by the answer to another question by #Florian at How can i create Path space markup element in Anylogic via Code, I have addressed the problem by adding all the nodes to a network, adding the network to a level, and then initializing the level. The updated code is below.
Network netwkSJ = new Network(this, "mynetwork");
....
LinkedHashMap<String,RectangularNode> floorLayout=new LinkedHashMap<String,RectangularNode>();
// the loop in the original question here
// added the following statement within the loop
.......
netwkSJ.add(shapeLayoutObj);
floorLayout.put(layoutName, shapeLayoutObj);
// Commented out the statement that was generating the error in the loop
// and moved it within the new loop below
//((Agent)temp).setLocation(shapeLayoutObj); // statement giving error
.......
Level level = new Level(this, "myLevel", SHAPE_DRAW_2D3D, 0);
level.add(netwkSJ);
level.initialize(); // cannot be changed after initialization!
Set set = floorLayout.entrySet();
// iterating through elements of floorLayout to link machines to corresponding layout locations
floorLayout.forEach((Name,node) -> {
//Associate the node with a machine
Iterator<ArrayList<Machine>> cell=machineList.iterator();
boolean foundAgent=false;
while(cell.hasNext()&&!foundAgent){
Iterator<Machine> machines=cell.next().iterator();
while(machines.hasNext()&&!foundAgent){
Machine temp=((Machine)machines.next());
if(temp.name.equals(Name)){
foundAgent=true;
((Agent)temp).setLocation(node);
// System.out.println(Name + " -> " );
}
};
};
});
I was adding some images into the table with labels on the side, but the images are pushing the labels quite far away and hence distorting the overall layout.
The images are 640x640 in resolution.
The layout:
I tried playing around with cell functions and tried padding the different rows and columns (kind of worked however this is not what I'm going for as it displaces the whole of the table's components) and I have read the table documentation in GitHub here, however I'm still stuck with the same issue.
Here is the table layout code (table initialised in class constructor)
int[] values;
ArrayList<Label> labels = new ArrayList<>();
//just setting up labels with according values, not really important
if (label.getText().toString().contains("Conjurer")) values = new int[]{200, 9, 10, 15, 15};
else if (label.getText().toString().contains("Monk")) values = new int[]{300, 14, 15, 11, 8};
else values = new int[]{320, 14, 17, 9, 13};
//creating new labels and adding to list
for (int i = 0; i <= 4; i++) {
Label l = new Label(String.valueOf(values[i]), UI.createNewLabelStyle(font, Color.WHITE)); //temp label to add
labels.add(l);
}
Image healthIcon = new Image(stat_atlas.findRegion("healthIcon"));
Image defenseIcon = new Image(stat_atlas.findRegion("defenseIcon"));
Image attackIcon = new Image(stat_atlas.findRegion("attackIcon"));
Image magicAttackIcon = new Image(stat_atlas.findRegion("magicAttackIcon"));
Image magicDefenseIcon = new Image(stat_atlas.findRegion("magicDefenseIcon"));
table.setDebug(true);
table.row();
table.add(healthIcon).height(60f).width(60f);
table.add(labels.get(0));
table.row();
table.add(attackIcon).height(60f).width(60f).right();
table.add(labels.get(1));
table.row();
table.add(defenseIcon).height(60f).width(60f).right();
table.add(labels.get(2));
table.row();
table.add(magicAttackIcon).height(60f).width(60f).right();
table.add(labels.get(3));
table.row();
table.add(magicDefenseIcon).height(60f).width(60f).right();
table.add(labels.get(4));
table.row();
What I would like is to find a way for the images not to span such a wide area (the red line should just encapsulate the image only and not go beyond it)
Thank you so much!
What happened is your back button only takes up one column, so all the labels in the second column have to appear to the right of it. When you add the back button, call colSpan(2) on the returned Cell. Also, when you add the labels, you may need to call left() on their returned Cells so they push against the images.
This will not necessarily center everything, because of the way Table distributes the extra space of the columns. If you need it all centered, you will actually need an inner table for everything besides your Back button.
I'm experiencing a weird graphical glitch on my application. The situation is that I am creating some GridPanes and adding them to a parent GridPane which is inside a ScrollPane. However, upon scrolling, some weird glitches begin occurring. Here is a picture:
(Sorry for having to use links, I don't have enough reputation to post images).
http://s11.postimg.org/x9eg8bz4z/Glitch.png
Here is a picture of what it should look like:
http://s11.postimg.org/cqjk39l7n/Normal.png
Here is my code:
private static class Controller implements Initializable {
#FXML private GridPane projectsPane;
#Override
public void initialize(URL location, ResourceBundle resources) {
//I first create some objects to be used when
//creating the GridPanes in the following loop,
//but I have removed the code for simplicity
for(AvailableProject availableProject : availableProjects) {
GridPane projectPane = new GridPane();
projectPane.setBackground(new Background(new BackgroundFill(Color.DARKGREY, CornerRadii.EMPTY, Insets.EMPTY)));
ColumnConstraints column1 = new ColumnConstraints();
column1.setPercentWidth(50);
ColumnConstraints column2 = new ColumnConstraints();
column2.setPercentWidth(50);
projectPane.getColumnConstraints().addAll(column1, column2);
projectPane.setPadding(new Insets(5));
Label projectName = new Label(availableProject.projectName);
GridPane.setValignment(projectName, VPos.CENTER);
projectPane.add(projectName, 0, 0);
TextFlow description = new TextFlow(new Text(availableProject.description));
description.setMaxSize(200, 100);
GridPane.setValignment(description, VPos.CENTER);
projectPane.add(description, 0, 1);
Label category = new Label(availableProject.category);
GridPane.setValignment(category, VPos.CENTER);
GridPane.setHalignment(category, HPos.RIGHT);
projectPane.add(category, 1, 0, 1, 2);
projectsPane.add(projectPane, 0, yRow);
yRow++;
Pane pane = new Pane();
pane.setMinHeight(15);
projectsPane.addRow(yRow, pane);
yRow++;
}
}
}
I have tried simplifying the code to make it cleaner, but I will post the rest if needed.
Thank you!
I seem to have found the solution. By the looks of it, this really is a bug. I will report it to Oracle later. It seems the problem was that I had padding in my ScrollPane. By my testing, if padding was greater than 5, the glitches would occur. A workaround is to assign the padding to the parent GridPane rather than the ScrollPane.
I have a problem : moving a tab of a tabpane from the index 0 to 1 isn't working anymore.
I updated recently the new version of java (8u20). Since then, the "moving tab" feature of my program doesn't work anymore.
Here's my code :
final TabPane tabPane = new TabPane();
final Tab tabOne = new Tab("hello");
Label label1 = new Label("hello");
tabOne.setContent(label1);
tabOne.getContent().setOnMouseClicked(new EventHandler<MouseEvent>() {
#Override
public void handle(MouseEvent event) {
tabPane.getTabs().remove(tabOne);
tabPane.getTabs().add(1, tabOne);
tabPane.getSelectionModel().select(1);
}
});
Tab tabTwo = new Tab("byebye");
tabPane.getTabs().add(tabOne);
tabPane.getTabs().add(tabTwo);
As you can see, the code is quite simple : I have two tabs, and I just move the first tab from index 0 to index 1 when a click occurs on its content.
This code works with jre8, but doesn't with jre1.8.0_20 (the tabs disappear ...).
Does someone have an idea of why is this happening ?
Thanks for any help
It is probably this bug:
https://javafx-jira.kenai.com/browse/RT-38490
...which is fixed in the latest 8u40 early access build.
IntelliJ Idea GUI designer doesn't provide source code of generated JForm. I tried with File>Settings>GUI Designer> Java source Code, but there's no effect. What I get is something like this, and it looks different than on a preview.
private void $$$setupUI$$$() {
panel1 = new JPanel();
panel1.setLayout(new com.intellij.uiDesigner.core.GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
tabbedPane1 = new JTabbedPane();
panel1.add(tabbedPane1, new com.intellij.uiDesigner.core.GridConstraints(0, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_BOTH, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(200, 200), null, 0, false));
final JPanel panel2 = new JPanel();
panel2.setLayout(new com.intellij.uiDesigner.core.GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
tabbedPane1.addTab("Log In", panel2);
final JPanel panel3 = new JPanel();
Also there is error warnings "cannot resolve symbol 'intellij'"
How to fix it?
The source generated by IDEA (as will be stated by a lot of the comments also output) isn't something that is meant to be edited.
It's unclear what was meant in your question regarding what looks different: Did you mean from how you think it should look given what the preview looks like? Or that the resultant gui that the code produces does look different ... if the later - please provide all source code to enable us to take a deeper look.
The warnings are because the classes (such GridLayoutManager) are not visible to the IDE/compiler until runtime. However, if the program is run from IDEA - it should execute just fine since the forms_rt.jar (that contains this and other useful classes) will be present in the classpath.
Please see http://www.jetbrains.com/idea/webhelp/gui-designer.html for more details.