Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help with my Java and I have the DrawingPanel.java, FmlElement.java, FmlP

ID: 3838418 • Letter: I

Question

I need help with my Java and I have the  DrawingPanel.java, FmlElement.java, FmlParser.java, FmlRenderer.java, Main.java file but the DrawingPanel.java is too long and it is not letting me post it here. Is there any other way I can share it with you? Thanks

here is a drobbox link

https://www.dropbox.com/sh/8bdo15p5ss6jq8n/AAD0Tx2eMEploCqM0d4vOdPda?dl=0

file:///Users/haime/Downloads/CSC%20143%20Assignment%202%20(2).pdf

Overview. We will implement a parser and renderer by supporting documents consisting of lists of elements. We will not worry about attributes, children, or nested elements in this implementation. Our subset of FML only contains 2 elements: document paragraph Your program will read FML documents from a file containing multiple elements and produce output in a DrawingPanel. For example: 1. some text this is text within a paragraph element 2. this document only contains one element 3. the first line the order of the elements should be preserved an element can occur many times Five files are provided to start the assignment: DrawingPanel.java, defining a DrawingPanel object to create a graphical user interface; FmlElement.java, defining the FmlElement object, an abstract base class for all elements; FmlParser.java, defining the FmlParser interface; FmlRenderer.java, defining the FmlRenderer interface; and Main.java, defining a class with the main() method. These files may not be changed, except for Main.java, which may be altered to read different FML documents. You will add classes to convert files containing FML documents into an appropriate element class (e.g. DocumentElement or ParagraphElement) and render the element in a DrawingPanel. The following UML diagram illustrates the relationship between the provided classes and those you are expected to implement. Figure 1: A UML diagram illustrating the relationship between the classes involved in the FML browser. Part 1. Read an FML file and convert it into a list of element objects. You must produce subclasses for each element type (e.g. DocumentElement) and for the parser (FileParser). The element classes must extend the FmlElement base class. The parser must implement the FmlParser interface. The table below illustrates the mapping between elements and classes: Element Class DocumentElement ParagraphElement Table 1. A mapping from an FML element to class. Each class derives from the FmlElement base class. Part 2. Render the FML elements from the previous step into a DrawingPanel of width 640 pixels and height 480 pixels. The first element should be offset by 8 pixels from the left and 16 pixels from the top of the drawing panel. Each subsequent line must be offset by 16 pixels from the one above it. Use 12 point Times New Roman as the font to render the element text. Write the renderer code in a new class, DrawingPanelRenderer, implementing the FmlRenderer interface. All elements will be displayed in the same manner by printing the element’s text on a new line. Assignment 2 3 FML Document Rendered Document Some text. this is text within a paragraph element Some text. this is text within a paragraph element this document only contains one element this document only contains one element the first line the order of the elements should be preserved an element can occur many times the first line the order of the elements should be preserved an element can occur many times

FmlElement.java

/**

* Creates a new FML element with the given name and text.

*

* @param name

* The element name.

* @param text

* The element text.

*/

public FmlElement(String name, String text) {

this.name = name;

this.text = text;

}

/**

* Returns the name of the element.

*/

public String name() {

return name;

}

/**

* Returns the text of the element.

*/

public String text() {

return text;

}

@Override

public String toString() {

return String.format("<%s>%s", name, text, name);

}

}

FmlParser.java

import java.util.List;

/**

* An interface for FML parsers.

*/

public interface FmlParser {

/**

* Returns the root elements of the FML document.

*/

List roots();

}

Fmlrenderer.java

/**

* An interface for FML renderers.

*/

public interface FmlRenderer {

/**

* Renders an FML element.

*

* @param element

* The element to be rendered.

*/

void render(FmlElement element);

}

Main.java

import java.io.IOException;

public class Main {

public static void main(String[] args) {

try {

FmlParser parser = new FileParser("src/paragraph.fml");

FmlRenderer renderer = new DrawingPanelRenderer();

for (FmlElement element : parser.roots()) {

renderer.render(element);

}

} catch (IOException e) {

System.err.println(e);

}

}

}

Explanation / Answer

FmlElement.java

/**

* Creates a new FML element with the given name and text.

*

* @param name

* The element name.

* @param text

* The element text.

*/

public FmlElement(String name, String text) {

this.name = name;

this.text = text;

}

/**

* Returns the name of the element.

*/

public String name() {

return name;

}

/**

* Returns the text of the element.

*/

public String text() {

return text;

}

@Override

public String toString() {

return String.format("<%s>%s", name, text, name);

}

}

FmlParser.java

import java.util.List;

/**

* An interface for FML parsers.

*/

public interface FmlParser {

/**

* Returns the root elements of the FML document.

*/

List roots();

}

Fmlrenderer.java

/**

* An interface for FML renderers.

*/

public interface FmlRenderer {

/**

* Renders an FML element.

*

* @param element

* The element to be rendered.

*/

void render(FmlElement element);

}

Main.java

import java.io.IOException;

public class Main {

public static void main(String[] args) {

try {

FmlParser parser = new FileParser("src/paragraph.fml");

FmlRenderer renderer = new DrawingPanelRenderer();

for (FmlElement element : parser.roots()) {

renderer.render(element);

}

} catch (IOException e) {

System.err.println(e);

}

}

}

for Drawing panel.java , you can post in seperate question and make sure to give the summary of FmlElement.java, FmlParser.java, FmlRenderer.java and Main.java. If you try to post all the code here you may hit the limit of maxLength. Please provide only summary that sould be sufficient to solve the question. Also contact to chegg team on its forum or support for how to post long questions

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote