cs193p – Assignment #6 Task #2 Part #1

Please note, this blog entry is from a previous course. You might want to check out the current one.

Recreate the user-interface from last week’s assignment but rely entirely on the above-mentioned Core Data database to present it.

Start by copying the content of story board for the iPhone of the previous SPoT project into the current project. Copy the class files for the first table-view controller of the first tab of the previous project together with the files for the network-activity indicator into the current project as well as the core-data-table-view controller from the demo of the lecture.

Define the table view controller as sub class of the ore-data-table-view controller:

@interface FlickrPhotoTagTVC : CoreDataTableViewController

Continue reading “cs193p – Assignment #6 Task #2 Part #1”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #6 Task #1

Please note, this blog entry is from a previous course. You might want to check out the current one.

Create a Core Data-managed object database model in Xcode suitable for storing any information you queried from Flickr in the last assignment that you feel you will need to perform the rest of the Required Tasks in this assignment. Take the time to give some thought to what Entities, Attributes and Relationships your database will need before you dive in.

Following the recommendations of the assignment create a new blank universal single-view project. Create a new data model. Start by adding two new Entities “Photo” and “Tag” to hold the photos and its tags. Add a many-to-many relationship between them, because a photo can have multiple tags and a tag can have multiple photos.

The first table view should show the name of the tag and the number of photos it is associated with. Create a new string attribute for the tag entity to hold the name. The number of photos will be derived using its relationship to the photo tags.
Continue reading “cs193p – Assignment #6 Task #1”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs106a – Assignment #6 – Extra Task #4

The complete specification of assignment #6 can be found as part of the stream at iTunes.

Adjust the font size as the application size changes

One of the wonderful features of this program is that it redraws itself to fill the available space if you change the size of the window. If you make it too small, however, the labels run together and become unreadable. You could eliminate this problem by choosing a font size that allows each label to fit in the space available.

Check if the label is wider than the column, if so adjust the font size:

	private void adjustSizeOfLabel(GLabel label) {
		double dx = getWidth() * 0.85 / NDECADES;
		double labelWidth = label.getWidth();
		if (labelWidth > dx) {
			Font font = label.getFont();
			label.setFont(font.deriveFont((float) (dx * font.getSize() / labelWidth)));
		}		
	}

	private void drawLabel(NameSurferEntry entry, int index, double x, double y) {
		...
		adjustSizeOfLabel(label);
		...
	}

	private void drawGrid() {
			...
			GLabel label = new GLabel(" " + year, x, yText);
			adjustSizeOfLabel(label);
			add(label);
			...
	}

The code for this assignment is available on github.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs106a – Assignment #6 – Extra Task #3

The complete specification of assignment #6 can be found as part of the stream at iTunes.

Try to minimize the overprinting problem

If the popularity of a name is improving slowly, the graph for that name will cross the label for that point making it harder to read. You could reduce this problem by positioning the label more intelligently. If a name were increasing in popularity, you could display the label below the point; conversely, for names that are falling in popularity, you could place the label above the point. An even more challenging task is to try to reduce the problem of having labels for different names collide, as they do for Sam and Samantha.

For the first task – moving the label below the graph if is ascending – the label drawing class needs more information about the graph thus it is better to provide the complete entry instead of the name and rank only:
Continue reading “cs106a – Assignment #6 – Extra Task #3”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs106a – Assignment #6 – Extra Task #2

The complete specification of assignment #6 can be found as part of the stream at iTunes.

Allow deletion as well as addition

Because the screen quickly becomes cluttered as you graph lots of names, it would be convenient if there were some way to delete entries individually, as opposed to clearing the entire display and then adding back the ones you wanted. The obvious strategy would be to add a Delete button that eliminated the entry corresponding to the value in the Name box. That approach, however, has a minor drawback given the design so far. If you added a bunch of entries to the graph and then deleted the early ones, the colors of the later entries would shift, which might prove disconcerting. Can you redesign the color-selection strategy so that displayed entries retain their color even if other entries are removed?

Add the delete button to the main class:
Continue reading “cs106a – Assignment #6 – Extra Task #2”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs106a – Assignment #6 – Extra Task #1

The complete specification of assignment #6 can be found as part of the stream at iTunes.

Add features to the display

The current display contains only lines and labels, but could easily be extended to make it more readable. You could, for example, put a dot at each of the data points on the graph. Even better, however, would be to choose different symbols for each line so that the data would be easily distinguishable even in a black-and-white copy. For example, you could use little circles for the first entry, squares for the second, triangles for the third, diamonds for the fourth, and so on. You might also figure out what the top rank for a name is over the years and set the label for that data point in boldface.

Create a new data type to hold the possible forms of the markers:
Continue reading “cs106a – Assignment #6 – Extra Task #1”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs106a – Assignment #6 – Task #5

The complete specification of assignment #6 can be found as part of the stream at iTunes.

Complete the implementation of NameSurferGraph class

In addition to creating the background grid, the update method in NameSurferGraph also has to plot the actual data values. The NameSurferGraph class includes two methods for specifying what entries are displayed on the screen. The addEntry method adds a new NameSurferEntry to a list of values that are currently on the display. The clear method deletes all of the entries in that list so as to clear the graph.
There are a couple of points that you should keep in mind while implementing this part of the program:

  • To make the data easier to read, the lines on the graph are shown in different colors. In the sample applet on the web site, the first data entry is plotted in black, the second in red, the third in blue, and the fourth in magenta. After that, the colors cycle around again through the same sequence.
  • The fact that rank 1 is at the top of the window and rank 1000 is at the bottom means that it can sometimes seem confusing that rank 0—which means that the name does not appear in the top 1000 values for that year—appears at the bottom. To reduce the apparent discontinuity between rank 1 and rank 0, the entries for names that are absent from the data for a decade are listed with an asterisk instead of a numeric rank.

Continue reading “cs106a – Assignment #6 – Task #5”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail