We are going to use PostgreSQL as our database. It is a popular choice among Ruby On Rails community. If you haven’t created any Rails apps with PostgreSQL yet, you may want to check this tutorial. Once you are familiar with PostgreSQL, navigate to a directory where you keep your projects and open a command line prompt. By default Rails uses SQlite3, but since we want to use PostgreSQL as our database, we need to specify it by adding: -database=postgresql To generate a new app run this line: rails new collabfield -database=postgresqlĬollabfield, that’s how our applications is going to be called. Navigate to a newly created directory by running the command: cd collabfieldĪnd now we can run our app by entering: rails s Now we should’ve successfully generated a new application. Now we should be able to see what we got so far. Open a browser and go to If everything went well, you should see the Rails signature welcome page. When we go to we see the Rails welcome page. We’re going to switch this default page with our own home page. In order to do that, generate a new controller called Pages. If you are not familiar with Rails controllers, you should skim through the Action Controller to get an idea what the Rails controller is. Run this line in your command prompt to generate a new controller. The output in the command prompt should look something like this: This rails generator should have created some files for us. We are going to use this PagesController to manage our special and static pages. Now open the Collabfield project in a text editor. Open a file pages_controller.rb app/controllers/pages_controller.rb I use Sublime Text, but you can use whatever you want to. Of course we could define home page in a different controller and in different ways. When we open pages_controller.rb, we see this: class PagesController Home page But usually I like to define the home page inside the PagesController. Now when we go to we should see something like this instead of the default Rails information page. We can start introducing new things to our website. If you don’t already know, when we generate a new application, a new local git repository is initialized.Īdd all current changes by running: git add -A I think it’s time to create our first commit. Specify the location where you want to store your model files. (P.S.Then commit all changes by running: git commit -m "Generate PagesController. In the Model name edit box, type Road Traffic Tutorial. ShapeGroup outerGroup = new ShapeGroup(this, SHAPE_DRAW_2D3D, true, 170.0, 20.0, 0.0, 0.0, innerGroup ) ShapeGroup innerGroup = new ShapeGroup(this, SHAPE_DRAW_2D3D, true, 170.0, 20.0, 0.0, 0.0, myProgramticall圜reatedText ) Like below Font _text_Font = new Font("SansSerif", 0, 10 ) If you want to make it visible in 3d and also rotate it correctly you need to create a group, add the text to that group, then create a new group, and the group this new group and then rotate the first group. ShapeText(ShapeDrawMode drawMode, boolean ispublic, double x, double y, double z, double rotation, color, text, font, TextAlignment alignment)Ĭonstructs a text shape with specific attributes.ĭepending on whether or not you have 3D or not you can rotate the text by changing the correct parameters Here is the syntax for creating your ShapeText(boolean ispublic, double x, double y, double rotation, color, text, font, TextAlignment alignment)Ĭonstructs a 2D-only text shape with specific attributes. Presentation.add(myProgramticall圜reatedText) ShapeText myProgramticall圜reatedText = new ShapeText( You can use the code snipped below to draw a Text object and add it to the presentation collection (which is needed for it to be displayed) Font _text_Font = new Font("SansSerif", 0, 10 ) // Only needed if you don't have any text in your agent else _text_Font gets created for you. There is a little trick in AnyLogic where you can view the code that gets created for you by AnyLogic discussed in this blog post If you are creating walls dynamically I assume you also want to create your text dynamically.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |