I am trying to print a prefix tree, I already modeled the trie class, I need to print the prefix tree something like:
enter image description here
But I can't figure out how to create it in a perfect way, I'm using the iTextPdf library, but I've only made the Root node, but when trying to create the next one I can't center the text, divide the page or something similar, I wanted to know if any of them have a best solution or have any idea to do it. Thank you
Related
I tried to make my day easier making a program that will register my self into card game tournaments via selenium webdriver. I am beginner so I was thrilled even though it was just basics aka click here, confirm this, write that but at the end I ran into a problem that I am having trouble solving.
At the end you need to submit decks via deck code. The sendKeys function? (not sure if thats the correct wording) does not work since it actually needs to be pasted into the text area. Whenever you try to "just" write into the box it says its invalid deck code.
driver.findElement(By.xpath("//*[#id=\"react-root\"]/div/div/div[2]/div/div[2]/div/div[4]/div[1]/div/textarea")).click();
driver.findElement(By.xpath("//*[#id=\\\"react-root\\\"]/div/div/div[2]/div/div[2]/div/div[4]/div[1]/div/textarea")).sendKeys(Keys.chord(Keys.CONTROL + "v"));
I went with this, first line just clicking in to the text area and then trying to paste it in (while I copied the deck code manually, not sure how I will solve this since I need to paste 3 different ones, but that is issue for the future) but the code just wont paste and I have no idea where is the catch. I tried the paste function in different text area with the same settings meaning I have something copied in my clipboard and it worked just fine.
Example of the deck code is
" AAECAZICCiT3A94FrtICv/IC9fwC2KAD+KED9KID/KMDCkBWX/4BxAapogPIogPcogPvogPZqQMA "
I hope I provided everything I should have otherwise let me know and I will gladly post more :) Thanks in advance and I hope someone can help me
This might not work because I don't see you explicitly copying the deck code, as you mentioned you did it manually. I also modified your example to not use Keys.chord, as you might not need them here.
To copy the element:
deckCodeWebElement = driver.findElement(locatorToFindDeckCode);
deckCodeWebElement.send_keys(Keys.CONTROL+'a')
time.sleep(1)
deckCodeWebElement.send_keys(Keys.CONTROL+'c')
Then, to paste:
deckCodeWebElementToPaste = driver.findElement(locatorToFindDeckCodeToPaste);
deckCodeWebElementToPaste.send_keys(Keys.CONTROL+'v')
On another note, I recommend shortening your XPaths to relative notation, as the absolute notation you are using is very brittle and breaks very easy. You want to find elements irrespective of their location in the DOM tree.
You can change this:
//*[#id=\\\"react-root\\\"]/div/div/div[2]/div/div[2]/div/div[4]/div[1]/div/textarea
to just this:
//textarea
You may need to query on something like ID, class, or name if there are multiple textarea elements, but there is no need to start at the root node and use div[2] and div[4] unless absolutely necessary.
I need to write an editor with two Trees, where user can map nodes from one tree to another. The biggest challenge is to draw connection line between TreeItems.
Are there any samples that I can use?
There is the link for JDeveloper XSD Mapper tree view
https://technology.amis.nl/wp-content/uploads/images/xsdMapper.jpg
There is a related question here.
There is also the Nebula TreeMapper. Looks like this:
I would like to prepare function which will give me position of node in xml.
For example:
int NodePosition = doc.getDocumentElement().getChildNodes().item(t).getNodeName().Position()
and in future I would like make some like this (of course this is example):
System.out.println(Node.row[NodePosition].tostring());
Is it possible to make something like this? Or maybe you know some function which make something like this.
For example when I go deeper there is a problem to get position. Because m = 7
doc.getDocumentElement().getChildNodes().item(t).getChildNodes().item(m)
When I try make this (but I have to save position):
System.out.println(doc.getDocumentElement().getChildNodes().item(7).getNodeName());
I get error
java.lang.NullPointerException
To me it looks like you are reinventing the wheel - you are trying to build your own version of XPath - See: http://www.ibm.com/developerworks/library/x-javaxpathapi/index.html
How to select specified node within Xpath node sets by index
I have a list of data in a JList component in my GUI.
I would like to know if there is a method that i can call on the list element(s) to strike through a particular element in the list. I would like to draw a line through the element to appear as if that element is canceled.
I want a similar thing like the strike through functionality in Microsoft Word document whereby a line i drawn through the text.
thanks for your help
You can apply html formating to each element of a list. Therefore if you know what element you want struck through you can modify the string held by that element as such:
<html><strike>this text will be struck through</strike></html>
Edit: I should note that I haven't tested this so if the strike tag isn't supported in Java try just s. One of those should work
JIDE Common Layer has a StyledListCellRenderer that can be used to provide this functionality.
I am displaying text in a Java JEditorPane using HTML to fomrat the text. I am also designing a search function that finds text in the JEditorPane selects the text and then scrolls to it. My problem is creating an algorithim that will actually specify the beginning and ending position for the selection.
If I simply retrieve the text using myeditorpane.getText(), then find the search string in the result, the wrong selection start and end positions are calculated with the wrong text being selected (the tags are throwing the calculation off). I tried removing the html tags by executing a replace all function text.().replaceAll("\<.*?>","") before searching for the text (this replace all removes all text in between the tags) but still the wrong selection points are calculated (although I'm getting close :-)).
Does anyone have an easy way to do this?
Thanks,
Elliott
You probably want to be working with the underlying Document, rather than the raw text, as suggested in this HighlightExample.
You need to find the start location of the text. I guess something like:
int offset = editorPane().getDocument().getText().indexof(...);
Then to scroll you can use:
editorPane.scrollRectToVisible( editorPane.viewToModel(offset) );
Read up on Text and New Lines for more info.