I've been working on a GUI to handle DNA sequences. Most of the molecules will be plasmids, which are circular forms of DNA. I can get a sequence as a string and display it in a JTextPane, but I'm not sure how to handle cases where the user might want to select a section of the sequence that crosses from the end to the beginning of the sequence. One thing I've considered is displaying the sequence twice, so you can select the last part of the first section and the first part of the last section, then overwriting some function so that copying the text will put the correct sequence on the clipboard instead of the string that was actually selected. (I'll have to do that anyway, I'm displaying the forward and reverse strands of the DNA, then a blank line, so that 1 "line" of actual sequence becomes 3 lines of text.
Is there some trick to circular strings that I just don't know about?
Do you know how other programs handle the selection of pieces of circular DNA? You might be able to get some inspiration from other software, like alignment viewers (supporting circular DNA) in this list on Wikipedia: en.wikipedia.org/wiki/List_of_alignment_visualization_software.
I think it would be wise to decide on how you want the GUI to work first, and then start working on your code. Otherwise you risk wasting a lot of time on implementing ideas that you end up not using.
You could even consider offering both a circular and a linear view on the same sequencing data, as this screenshot from the CLC Sequence Viewer shows:
Related
I'm sorry if the title is vague. It's because I don't know exactly what it is called.
I am creating a program for a school project and I'm trying to figure out a shorter version of a code that I already got.
The interface looks like this:
Interface
The other parts of the program are not really necessary to put on here. They just input texts/strings in the first row textfields and shifts down one column every time new info is put in the first row.
The buttons on the right (the ones with the [x]) are the ones that are coded. They remove the text/string in the row next to them and shifts up the texts from below (if there are any) by one column.
The code for the first button is such:
CC01.setText(CC02.getText());
SC01.setText(SC02.getText());
SU01.setText(SU02.getText());
SD01.setText(SD02.getText());
SR01.setText(SR02.getText());
CC02.setText(CC03.getText());
SC02.setText(SC03.getText());
SU02.setText(SU03.getText());
SD02.setText(SD03.getText());
SR02.setText(SR03.getText());
CC03.setText(CC04.getText());
SC03.setText(SC04.getText());
SU03.setText(SU04.getText());
SD03.setText(SD04.getText());
SR03.setText(SR04.getText());
CC04.setText(CC05.getText());
SC04.setText(SC05.getText());
SU04.setText(SU05.getText());
SD04.setText(SD05.getText());
SR04.setText(SR05.getText());
CC05.setText(CC06.getText());
SC05.setText(SC06.getText());
SU05.setText(SU06.getText());
SD05.setText(SD06.getText());
SR05.setText(SR06.getText());
CC06.setText(CC07.getText());
SC06.setText(SC07.getText());
SU06.setText(SU07.getText());
SD06.setText(SD07.getText());
SR06.setText(SR07.getText());
CC07.setText(CC08.getText());
SC07.setText(SC08.getText());
SU07.setText(SU08.getText());
SD07.setText(SD08.getText());
SR07.setText(SR08.getText());
CC08.setText(CC09.getText());
SC08.setText(SC09.getText());
SU08.setText(SU09.getText());
SD08.setText(SD09.getText());
SR08.setText(SR09.getText());
CC09.setText(CC10.getText());
SC09.setText(SC10.getText());
SU09.setText(SU10.getText());
SD09.setText(SD10.getText());
SR09.setText(SR10.getText());
CC10.setText("");
SC10.setText("");
SU10.setText("");
SD10.setText("");
SR10.setText("");
So, yes, I have ten of these buttons. And the code for each button reduces by one 5-line code. For example, Button1's code is the one you see up top, then Button2's code starts from the [CC02...], the Button3 starts from [CC03], etc.
I think I used the brute force method of this code which I don't think is efficient and makes my code too long (the code for the ten [x] buttons alone is around 400 lines).
I asking of there is a much shorter way of doing this method.
Thanks.
Is there a way to adjust the spacing between new lines when outputting to the console through System.out.println? I'm attempting to print out a square with a basic nested for-loop, but I keep getting a rectangle despite having the right number of characters. This is because the spacing between the characters is different than the spacing between lines. Any ideas?
The standard output stream is just a stream of data; how that data is displayed is up to the application displaying it (e.g. a terminal or your IDE). You'll either have to settle for a rectangle, or find a different method of output than standard out.
Without your current code, it's hard to say exactly whats going on. My first thought is, make sure you're using a character that is as high as it is wide, e.g. *.
Second thought is (and again, I have no code to reference), see if you get the same result using one of the algorithms here: Printing a Square with loops, perhaps there is an issue with the square-printing logic that you overlooked.
We have a requirement where we already have pre printed stationery and want user to put data in a HTML form and be able to print data on that form. Alignment/text size etc are very important since the pre-printed stationery already has boxes for each character. What could be a good way to achieve this in java? I have thinking of using jasper reports. Any other options? May be overlay image with text or something?
Also we might need to capability to print on plain paper in which case the boxes needs to be printed by our application and the form should match after the printed with the already printed blank stationery containing data.
Do we have some open source framework to do such stuff?
Jaspersoft reports -- http://sourceforge.net/projects/jasperreports/
You will then create XML templates, then you will be able to produce a report in PDF, HTML, CSV, XLS, TXT, RTF, and more. It has all the necessary options to customize the report. Used it before and recommend it.
You will create the templates with iReport then write the code for the engine to pass the data in different possible ways.
check http://www.jaspersoft.com/jasperreports
Edit:
You can have background images and overlay the boxes over it and set a limit on the max character size ... and many more
It is very powerful and gives you plenty of options
Here is one of iReport's tutorial for a background image http://ireport-tutorial.blogspot.com/2008/12/background-image-in-ireport.html
The big problem when printing form content that has been filled in electronically, is aligning it correctly on the pre-printed form. You may get content to align for one printer, but when you use another it is completely misaligned.
Fly Software have a form design product called InForm Designer that gets around the problem nicely by allowing users to specify and save vertical and horizontal offsets for printers. This ensures filled in form content is always aligned. I've tried it and it works perfectly. Take a look for yourself here...
http://www.flysoftware.com/products/inform_designer/overview.asp
It might be worth implementing a printer offset similar to InForm's in your own application (if possible).
Some things to think about.
First in terms of the web page, do you want use the stationery as the form layout?
Does it have to be exact?
Combed boxes (one for each character)
Do you want to show it like that on the web page, or deal with the combing later.
How are you going to deal with say a combed 6 digit number. Is this right aligned. What if they enter 7 digits. Same for text. what if it won't fit.
Font choices, we had a lot of fun with W...
How aligned do you want the character within the box, what font limitations does that imply, some of the auto magic software we looked at did crap like change the size of each character.
Combed editing is a nightmare, we display combed, but raise an edit surface the size of the full box on selection.
Another thing that might drive you barking mad, you find find small differences in the size and layout of the boxes, so they look okay from a distance but a column of boxes sort of shifts about by a pixel. Some of testing guys had to lend us their electron microscopes, so we could see how many ink molecules we were out by. :(
Expect to spend a lot of time in the UI side of things, and remember printed stationery changes, so giving yourself some sort of meta description of the form to start with will save you loads of trouble later on.
In the application that I am working on, there is tabular data (for the record, it is a Java Swing app using JTables). In some cases the data is sortable by clicking on the column headers.
What I want to know is what is a good way to indicate to the user if a given column is sortable or not?
I have come up with the following possibilities.
1) Put an icon in each sortable column indicating it is sortable. I personally do not like this option.
2) Change the mouse cursor into something else when it hovers over the header to indicate it is sortable.
3) Put a note in the tooltip text when hovering over the column saying that it is sortable.
Does anyone have any other suggestions?
Update:
I think a clarification is in order.
My question is not how does one indicate that a given column is currently sorted. That is already implemented via the up/down sort triangle paradigm.
I want to give the user a clue as to which columns can be sorted before they click on the header to sort it.
Update 2:
I think I should explain why I'm not entirely sold on option #1. It seems to me that if one is going to put an icon to indicate which columns are sortable then this will add to visual clutter. In such cases, sometimes the UI changes on "mouse over". Case in point: Windows Vista and 7 allows one to add a filter on a column yet the indicator for this does not appear until you hover over the header with the mouse.
When you're dealing with the UI, you have to put your mind into what the user will expect. I would almost always recommend staying with the paradigms that your users will expect. Therefore I would recommend a version of option 1)
RememberME's post describes how this could work - You can still use arrows in column headers - one option would be to put an arrow icon in the header, but change the state of that icon if it was sorted (e.g. highlight the up or down button if the dataset is currently sorted by this column.)
Edit:
A Windows Explorer example may not be the best example here. My original text quoted below:
In Windows Explorer and almost all
form datagrids there is a small icon,
usually an up or down arrow, that
indicates that a column is sortable.
Experiment with Windows Explorer to
see the way in which this works.
In many apps, triangles indicate sortable so I think that's the best way to convey the information to the user b/c it's a standard they're most likely familiar with.
I think the jquery plugin from DataTables.Net is a good example. You could take a look and see if you like the look/functionality of that and emulate it. Both an up and a down indicate sortable. Just one or the other indicate that it is being sorted. If they column is not sortable, there is no icon at all. Their example also changes the pointer from an arrow to the hand pointer to indicate that you can click on the header.
I think the standard way is essentially option 1: either display the data initially sorted with a little arrow pointing either up or down (ascending/descending), or sort+display the icon as soon as the column header is clicked.
I think having a little arrow or triangle icon below the column heading, which you can click to sort by that column is the best option, as it is easy to see visually and very intuitive to use.
Little triangular up/down sort icons are pretty much standard for sortable table views in desktop applications and web pages. You may not like them, but your users are probably used to them (even if they don't realize it).
You should of course change the mouse cursor over clickable elements.
You should always do 2 for anything clickable.
Number 1 is not bad, typically a triangle pointing up or down depending on the sort order.
To indicate clickability, you could also use blue, underlined text on sortable columns and plain dark gray text on nonsortables -- the http link appearance is a well-known device to virtually all users, but it would not convey sortability, per se. Rather, a user might expect clicking that to take them to some other screen or list, as a hyperlink typically does.
I may be a little dense, but what kinds of columns are not sortable?
Pretty much anything can be sorted; even if there is no strict "greater than" relationship, at least there will be an "equals", and then sorting simply means "bring equal things together".
Strings? Try alphabetical ordering. Images? Sort by percentage of red, green, blue (or if you want to get fancy, compare color histograms). Locations? Use distance to Rome or any other arbitrary location.
Sorting on some columns may be much more useful than sorting on others; but I have a hard time finding a column type were it is important to avoid sorting from taking place.
Okay, thus may seen kind of odd, but I wanted to get some suggestions from everyone here. I am a beginning Java developer (after 2 years of ASP.NET web development) and I have recently began working on my first Java project - a calculator. I realize that their are tons of calculators out there, but I thought it would be a good beginner project.
Anyway, here is what I need help with. Currently, I am using a Scrolling JTextArea for display (instead of a simple JTextField) that is approximately 5 rows tall. I want the user to be able to scroll through the list to see previous entries and such. The format of the box will be equation on one line and the program will generate the answer on the next and so on.
My real question is, how is the best way to implement this? My fist idea was to read through the JTextArea when equals is pressed, down to the last line and try to search that line for the operator (+, -, etc.) and the operands. Is this the best way to go about this? Although, this would work would work, I think it could get cumbersome and sounds very inefficient. I am open to any suggestions, even possibly replacing the JTextArea is some other component would work better.
Thanks!
There's no need to read through the JTextArea contents - use JTextArea.append() to add to the end. Here are some examples of JTextArea content manipulation:
JTextArea ta = new JTextArea("Initial Text");
// Insert some text at the beginning
int pos = 0;
ta.insert("some text", pos);
// Insert some text after the 5th character
pos = 5;
ta.insert("some text", pos);
// Append some text
ta.append("some text");
// Replace the first 3 characters with some text
int start = 0;
int end = 3;
ta.replaceRange("new text", start, end);
// Delete the first 5 characters
start = 0;
end = 5;
ta.replaceRange(null, start, end);
If you are open to different interfaces, you might want to try something like a JTextField at the top of your view, from which you can receive as input your 'new' inputted equation, and then below it with the same width a JList that would scroll to have all of the previous equations and their results. That would make parsing of the current formula much easier, and you would also have an easy time of keeping your previous formula and their results in a scrollable list, with the easy option of keeping the most recent on top.
your idea is interesting. so you would have a line such as.
2+2
then when pressing calculate would add the line
4
and so on then you could type in another equation.
it could work but as you said it wouldn't be the most efficient implementation... but that's just a tradeoff of getting the desired functionality.
If i were going to implement it the way you discribed (with a JTextArea) I'd use scanner, and scan the value string a line at a time.
if the line has +/- in it then do the calculation and add both the original line and the answer to a string.
the new string is the new value of the text field.
this method would get pretty cumbersom as you would be continually recalculating the users old entries more were added.
I guess if you continually stored the last line of the document, when you run out of lines, calculate the last stored and append the answer, then it wouldn't be so bad.
Here's what I would do:
use a JTextField to enter in the calculations, and a JList to display the old ones and their answers.
You could treat each line as a single operation. That way you could use the String array returned directly by:
String [] operations = textArea.getText().split("\n");
And then you'll know that exactly each one of them as a complete operation ( may be invalid, but that' another story )
Is this what you asked or do I totally misread you?
I think a simpler solution would actually use two components. A TextArea to hold the "history" of what's happened so far, and a textfield where the user inputs new entries.
Thanks to everyone who replied. You all gave me some ideas to think about. I think right now, I am going to go with my original idea of using a single JTextArea and try to find ways to optimize the process. If that gets too difficult (which is very possible), I will follow the majority's advice and use two separate fields. Thanks for replying everyone!